|
@@ -49,8 +49,7 @@
|
|
|
|
|
|
|
|
<view class="app-footer">
|
|
<view class="app-footer">
|
|
|
<button class="admin-button-com big default" @click="goBack()">取消</button>
|
|
<button class="admin-button-com big default" @click="goBack()">取消</button>
|
|
|
- <button v-if="option.ptItemId" class="admin-button-com big blue" formType="submit" @click="status = 1">添加</button>
|
|
|
|
|
- <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1">确认</button>
|
|
|
|
|
|
|
+ <button class="admin-button-com big blue" formType="submit">添加</button>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
</form>
|
|
</form>
|
|
@@ -72,7 +71,7 @@
|
|
|
const form = require("@/utils/formValidation.js");
|
|
const form = require("@/utils/formValidation.js");
|
|
|
import { getAllItemClass } from "@/api/item-class";
|
|
import { getAllItemClass } from "@/api/item-class";
|
|
|
import { getAllUnit } from "@/api/unit";
|
|
import { getAllUnit } from "@/api/unit";
|
|
|
- import { getAllCpClass,addCpFn,updateCpFn } from "@/api/cp"
|
|
|
|
|
|
|
+ import { getAllCpClass,addCpFn,updateCpFn,getPtCpInfo } from "@/api/cp"
|
|
|
import { addProduct,updateProduct,getProductDetail } from "@/api/product";
|
|
import { addProduct,updateProduct,getProductDetail } from "@/api/product";
|
|
|
import { getPtItemDetail } from "@/api/pt-item";
|
|
import { getPtItemDetail } from "@/api/pt-item";
|
|
|
import { mapGetters } from "vuex"
|
|
import { mapGetters } from "vuex"
|
|
@@ -86,25 +85,17 @@
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- status: 1,
|
|
|
|
|
- pcClassList:[],
|
|
|
|
|
currentImgData: [],
|
|
currentImgData: [],
|
|
|
cpClassList:[],
|
|
cpClassList:[],
|
|
|
form: {
|
|
form: {
|
|
|
- id:0,
|
|
|
|
|
name:"",
|
|
name:"",
|
|
|
classId:0,
|
|
classId:0,
|
|
|
className:'',
|
|
className:'',
|
|
|
cover:[],
|
|
cover:[],
|
|
|
- inTurn:100
|
|
|
|
|
|
|
+ inTurn:100,
|
|
|
|
|
+ ptCpId:0
|
|
|
},
|
|
},
|
|
|
- itemClassSelectedData:{},
|
|
|
|
|
- itemClassData:[],
|
|
|
|
|
- unitData:[],
|
|
|
|
|
- smallUnitSelectedData:{},
|
|
|
|
|
- bigUnitSelectedData:{},
|
|
|
|
|
hasRequest:0,
|
|
hasRequest:0,
|
|
|
- productData:{id:0},
|
|
|
|
|
headers:{token:''}
|
|
headers:{token:''}
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -112,9 +103,6 @@
|
|
|
...mapGetters(["getLoginInfo","getDictionariesInfo"])
|
|
...mapGetters(["getLoginInfo","getDictionariesInfo"])
|
|
|
},
|
|
},
|
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
|
- if(option.id){
|
|
|
|
|
- this.form.id = this.option.id
|
|
|
|
|
- }
|
|
|
|
|
const token = uni.getStorageSync('token')
|
|
const token = uni.getStorageSync('token')
|
|
|
this.headers.token = token
|
|
this.headers.token = token
|
|
|
},
|
|
},
|
|
@@ -128,69 +116,13 @@
|
|
|
this.$refs.classRef.close()
|
|
this.$refs.classRef.close()
|
|
|
this.form.classId = info.id ? info.id : 0
|
|
this.form.classId = info.id ? info.id : 0
|
|
|
this.form.className = info.name ? info.name : ''
|
|
this.form.className = info.name ? info.name : ''
|
|
|
- console.log(this.form)
|
|
|
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
|
},
|
|
},
|
|
|
notModify(){
|
|
notModify(){
|
|
|
this.$msg('不可修改')
|
|
this.$msg('不可修改')
|
|
|
},
|
|
},
|
|
|
- goStockDetail(item){
|
|
|
|
|
- this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+item.id+'&name='+item.name})
|
|
|
|
|
- },
|
|
|
|
|
- statusChange(e){
|
|
|
|
|
- this.form.status = e.detail.value ? 1 : 2;
|
|
|
|
|
- },
|
|
|
|
|
- changeStock(event){
|
|
|
|
|
- let num = Number(event.target.value)
|
|
|
|
|
- if(num > 0){
|
|
|
|
|
- this.form.status = 1
|
|
|
|
|
- }else{
|
|
|
|
|
- this.form.status = 2
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
goBack(){
|
|
goBack(){
|
|
|
- uni.navigateBack({ delta: 1 })
|
|
|
|
|
- },
|
|
|
|
|
- getPtItemInfo(ptItemId){
|
|
|
|
|
- getPtItemDetail({id:ptItemId}).then(res=>{
|
|
|
|
|
- if (this.$util.isEmpty(res.data)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Object.keys(this.form).forEach((i, index) => {
|
|
|
|
|
- this.form[i] = res.data[i];
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.currentImgData.push(res.data.cover)
|
|
|
|
|
- this.form.cover = [res.data.shortCover]
|
|
|
|
|
- this.form.classId = ''
|
|
|
|
|
- this.form.id = 0
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- getDetail() {
|
|
|
|
|
- return getProductDetail({ id: this.option.id }).then(res => {
|
|
|
|
|
- if (this.$util.isEmpty(res.data)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Object.keys(this.form).forEach((i, index) => {
|
|
|
|
|
- this.form[i] = res.data[i];
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.currentImgData.push(res.data.cover)
|
|
|
|
|
- this.form.cover = [res.data.shortCover]
|
|
|
|
|
-
|
|
|
|
|
- this.form.price = res.data.prePrice
|
|
|
|
|
-
|
|
|
|
|
- this.itemClassSelectedData = this.itemClassData.filter(
|
|
|
|
|
- e => this.form.classId == e.id
|
|
|
|
|
- )[0];
|
|
|
|
|
- this.smallUnitSelectedData = this.unitData.filter(
|
|
|
|
|
- e => this.form.smallUnitId == e.id
|
|
|
|
|
- )[0];
|
|
|
|
|
- this.bigUnitSelectedData = this.unitData.filter(
|
|
|
|
|
- e => this.form.bigUnitId == e.id
|
|
|
|
|
- )[0];
|
|
|
|
|
- this.productData = res.data
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ uni.navigateBack()
|
|
|
},
|
|
},
|
|
|
imgUploadSuccess(res) {
|
|
imgUploadSuccess(res) {
|
|
|
var _res = JSON.parse(res.data)
|
|
var _res = JSON.parse(res.data)
|
|
@@ -205,62 +137,35 @@
|
|
|
},
|
|
},
|
|
|
init() {
|
|
init() {
|
|
|
let that = this
|
|
let that = this
|
|
|
- if(!this.$util.isEmpty(this.option.ptItemId)){
|
|
|
|
|
- uni.setNavigationBarTitle({title: "确认产品信息"})
|
|
|
|
|
- }
|
|
|
|
|
if(this.hasRequest == 1){
|
|
if(this.hasRequest == 1){
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- this._getAllUnit().then(res=>{
|
|
|
|
|
- this._getAllItemClass().then(res => {
|
|
|
|
|
- if(this.form.id == 0){
|
|
|
|
|
- this.smallUnitSelectedData = this.unitData.filter(e => 2 == e.id)[0];
|
|
|
|
|
- this.bigUnitSelectedData = this.unitData.filter(e => 1 == e.id)[0];
|
|
|
|
|
- if(!this.$util.isEmpty(this.option.ptItemId)){
|
|
|
|
|
- this.getPtItemInfo(this.option.ptItemId)
|
|
|
|
|
- }
|
|
|
|
|
- }else{
|
|
|
|
|
- this.getDetail();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
this.hasRequest = 1
|
|
this.hasRequest = 1
|
|
|
-
|
|
|
|
|
|
|
+ //从平台导入花材
|
|
|
|
|
+ if(this.option.ptCpId){
|
|
|
|
|
+ let ptCpId = this.option.ptCpId
|
|
|
|
|
+ getPtCpInfo({id:ptCpId}).then(res=>{
|
|
|
|
|
+ if(res.code == 1){
|
|
|
|
|
+ that.form.name = res.data.info.name
|
|
|
|
|
+ that.form.inTurn = res.data.info.inTurn
|
|
|
|
|
+ that.form.ptCpId = res.data.info.id
|
|
|
|
|
+ that.currentImgData.push(res.data.info.cover)
|
|
|
|
|
+ that.form.cover.push(res.data.info.shortCover)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
getAllCpClass().then(res => {
|
|
getAllCpClass().then(res => {
|
|
|
that.cpClassList = res.data.list ? res.data.list : []
|
|
that.cpClassList = res.data.list ? res.data.list : []
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
- async _getAllUnit() {
|
|
|
|
|
- await getAllUnit().then(res => {
|
|
|
|
|
- if (this.$util.isEmpty(res.data)){
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- this.unitData = res.data.list;
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- async _getAllItemClass() {
|
|
|
|
|
- await getAllItemClass().then(res => {
|
|
|
|
|
- if (this.$util.isEmpty(res.data)){
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- this.itemClassData = res.data;
|
|
|
|
|
- });
|
|
|
|
|
},
|
|
},
|
|
|
confirmFn() {
|
|
confirmFn() {
|
|
|
if (this.$util.isEmpty(this.form.cover)) {
|
|
if (this.$util.isEmpty(this.form.cover)) {
|
|
|
this.$msg("请上传图片")
|
|
this.$msg("请上传图片")
|
|
|
return false
|
|
return false
|
|
|
- }
|
|
|
|
|
- let requestHost = addCpFn
|
|
|
|
|
- if(this.form.id && this.form.id != 0){
|
|
|
|
|
- requestHost = updateCpFn;
|
|
|
|
|
- }else{
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
let form = JSON.parse(JSON.stringify(this.form))
|
|
let form = JSON.parse(JSON.stringify(this.form))
|
|
|
uni.showLoading({mask:true})
|
|
uni.showLoading({mask:true})
|
|
|
- requestHost({...form,cover:this.form.cover[0]}).then(res => {
|
|
|
|
|
|
|
+ addCpFn({...form,cover:this.form.cover[0]}).then(res => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
if(res.code == 1){
|
|
if(res.code == 1){
|
|
|
this.$msg(res.msg)
|
|
this.$msg(res.msg)
|