|
|
@@ -48,7 +48,7 @@
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<div class="tui-title">库存</div>
|
|
|
<input v-model="form.stock" style="width:340rpx;" placeholder-class="phcolor" @focus="form.stock=''" @input="changeStock($event)" class="tui-input" name="stock" placeholder="请输入" type="digit"/>
|
|
|
- <button class="admin-button-com blue small" @click="goStockDetail(productInfo.id,productInfo.itemId)">查看明细</button>
|
|
|
+ <button v-if="productData.id" class="admin-button-com blue small" @click="goStockDetail(productData.id)">查看明细</button>
|
|
|
</tui-list-cell>
|
|
|
<tui-list-cell class="line-cell" :arrow="true">
|
|
|
<div class="tui-title">大单位</div>
|
|
|
@@ -66,7 +66,6 @@
|
|
|
</picker>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
-
|
|
|
<tui-list-cell class="line-cell" :arrow="true">
|
|
|
<div class="tui-title">小单位</div>
|
|
|
<picker
|
|
|
@@ -83,7 +82,6 @@
|
|
|
</picker>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
-
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<div class="tui-title">单位比</div>
|
|
|
<input
|
|
|
@@ -150,7 +148,7 @@
|
|
|
</tui-list-cell>
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title">状态</div>
|
|
|
+ <div class="tui-title">上架状态</div>
|
|
|
<div class="switch_bx">
|
|
|
<switch :checked="form.status == 2 ? false : true" @change="statusChange" style="transform: scale(0.8,0.8)" />
|
|
|
<text v-if="form.status == 1">上架</text>
|
|
|
@@ -158,9 +156,17 @@
|
|
|
</div>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">状态</div>
|
|
|
+ <div class="switch_bx">
|
|
|
+ <switch :checked="form.delStatus == 0 ? true : false" @change="delStatusChange" style="transform: scale(0.8,0.8)" />
|
|
|
+ <text v-if="form.delStatus == 0">启用</text>
|
|
|
+ <text v-else>停用</text>
|
|
|
+ </div>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
- <!-- 花材图片 -->
|
|
|
<div class="module-com input-line-wrap goods-wrap">
|
|
|
<div class="module-tit">
|
|
|
<span>花材图片</span>
|
|
|
@@ -171,10 +177,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <!-- button -->
|
|
|
<div class="app-footer">
|
|
|
<button class="admin-button-com big default" @click="goBack()">取消</button>
|
|
|
- <button class="admin-button-com big blue" formType="submit" @click="status = 1">确认</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>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
@@ -187,6 +193,7 @@ const form = require("@/utils/formValidation.js");
|
|
|
import { getAllItemClass } from "@/api/item-class";
|
|
|
import { getAllUnit } from "@/api/unit";
|
|
|
import { addProduct,updateProduct,getProductDetail,py } from "@/api/product";
|
|
|
+import { getPtItemDetail } from "@/api/pt-item";
|
|
|
|
|
|
export default {
|
|
|
name: "item-detail",
|
|
|
@@ -212,6 +219,8 @@ export default {
|
|
|
cover:'',
|
|
|
stockWarning:'',
|
|
|
status:2,
|
|
|
+ delStatus:0,
|
|
|
+ itemId:0,
|
|
|
},
|
|
|
itemClassSelectedData:{},
|
|
|
itemClassData:[],
|
|
|
@@ -219,7 +228,7 @@ export default {
|
|
|
smallUnitSelectedData:{},
|
|
|
bigUnitSelectedData:{},
|
|
|
hasRequest:0,
|
|
|
- productInfo:null
|
|
|
+ productData:null
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -232,12 +241,15 @@ export default {
|
|
|
watch:{
|
|
|
},
|
|
|
methods: {
|
|
|
- goStockDetail(id,itemId){
|
|
|
- this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+itemId})
|
|
|
+ goStockDetail(id){
|
|
|
+ this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+id})
|
|
|
},
|
|
|
statusChange(e){
|
|
|
this.form.status = e.detail.value ? 1 : 2;
|
|
|
},
|
|
|
+ delStatusChange(e){
|
|
|
+ this.form.delStatus = e.detail.value ? 0 : 1;
|
|
|
+ },
|
|
|
//如果库存被修改则花材状态变化
|
|
|
changeStock(event){
|
|
|
let num = Number(event.target.value)
|
|
|
@@ -278,9 +290,31 @@ export default {
|
|
|
this.itemClassSelectedData = this.itemClassData[e.detail.value];
|
|
|
this.form.classId = this.itemClassSelectedData.id;
|
|
|
},
|
|
|
- _getDet() {
|
|
|
- return getProductDetail({ id: this.option.id })
|
|
|
- .then(res => {
|
|
|
+ //从平台导入花材 shish 20210826
|
|
|
+ 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.form.cover = [res.data.shortCover]
|
|
|
+ this.form.stock = ''
|
|
|
+ this.form.itemId = ptItemId
|
|
|
+ this.form.classId = ''
|
|
|
+ this.form.status = 1
|
|
|
+ this.form.delStatus = 0
|
|
|
+ this.form.id = 0
|
|
|
+ this.form.cost = ''
|
|
|
+ this.form.addPrice =''
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getDetail() {
|
|
|
+ return getProductDetail({ id: this.option.id }).then(res => {
|
|
|
if (this.$util.isEmpty(res.data)) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -300,35 +334,35 @@ export default {
|
|
|
e => this.form.bigUnitId == e.id
|
|
|
)[0];
|
|
|
|
|
|
- this.productInfo = res.data
|
|
|
+ this.productData = res.data
|
|
|
|
|
|
});
|
|
|
},
|
|
|
init() {
|
|
|
+
|
|
|
+ //从平台导入花材
|
|
|
+ if(!this.$util.isEmpty(this.option.ptItemId)){
|
|
|
+ uni.setNavigationBarTitle({title: "确认花材信息"})
|
|
|
+ }
|
|
|
+
|
|
|
if(this.hasRequest == 1){
|
|
|
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];
|
|
|
- }else{
|
|
|
- this._getDet();
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
+ 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
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
async _getAllUnit() {
|
|
|
await getAllUnit().then(res => {
|
|
|
@@ -354,12 +388,28 @@ export default {
|
|
|
}
|
|
|
|
|
|
this.form.cover = this.form.cover[0]
|
|
|
- let host = this.form.id == 0 ? addProduct : updateProduct;
|
|
|
+
|
|
|
+ let requestHost = addProduct
|
|
|
+ if(this.form.id && this.form.id != 0){
|
|
|
+ requestHost = updateProduct;
|
|
|
+ }else{
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.stock) == false){
|
|
|
+ uni.showToast({title:"请填写库存,没有请填0",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.cost) == false){
|
|
|
+ uni.showToast({title:"请填写成本价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.addPrice) == false){
|
|
|
+ uni.showToast({title:"请填写加价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
let form = JSON.parse(JSON.stringify(this.form));
|
|
|
form.cover = this.$util.imgSubstr(form.cover);
|
|
|
- host({
|
|
|
- ...form
|
|
|
- }).then(res => {
|
|
|
+ requestHost({...form}).then(res => {
|
|
|
+
|
|
|
this.$msg("操作成功!");
|
|
|
|
|
|
//返回上一页带参数
|
|
|
@@ -435,7 +485,6 @@ export default {
|
|
|
];
|
|
|
// 进行表单检查
|
|
|
let formData = e.detail.value;
|
|
|
- console.log('form',formData)
|
|
|
let checkRes = form.validation(formData, rules);
|
|
|
// 验证通过!
|
|
|
if (!checkRes) {
|