|
|
@ -9,66 +9,30 @@ |
|
|
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple |
|
|
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple |
|
|
:maxCount="10"></u-upload> |
|
|
:maxCount="10"></u-upload> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label=" 供应商" required name="supplierId"> |
|
|
|
|
|
<uni-easyinput type="text" v-model="formData.supplierId" placeholder="请输入供应商" trim="all" /> |
|
|
|
|
|
<!-- <uni-easyinput type="text" v-model="formData.name" /> --> |
|
|
|
|
|
</uni-forms-item> |
|
|
|
|
|
<uni-forms-item label="货号" name="productSn" required> |
|
|
<uni-forms-item label="货号" name="productSn" required> |
|
|
<uni-easyinput type="text" v-model="formData.productSn" placeholder="请输入货号" trim="all" /> |
|
|
<uni-easyinput type="text" v-model="formData.productSn" placeholder="请输入货号" trim="all" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="条码" name="barcode" required> |
|
|
|
|
|
<uni-easyinput type="text" v-model="formData.barcode" placeholder="请输入条码" trim="all" /> |
|
|
|
|
|
</uni-forms-item> |
|
|
|
|
|
<uni-forms-item label="采购价" name="purchasePrice" required> |
|
|
|
|
|
<uni-easyinput type="digit" v-model="formData.purchasePrice" placeholder="请输入采购价" trim="all" /> |
|
|
|
|
|
</uni-forms-item> |
|
|
|
|
|
<uni-forms-item label="批发价" name="wholesalePrice" required> |
|
|
<uni-forms-item label="批发价" name="wholesalePrice" required> |
|
|
<uni-easyinput type="digit" v-model="formData.wholesalePrice" placeholder="请输入批发价" trim="all" /> |
|
|
<uni-easyinput type="digit" v-model="formData.wholesalePrice" placeholder="请输入批发价" trim="all" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="市场价" name="price" required> |
|
|
<uni-forms-item label="市场价" name="price" required> |
|
|
<uni-easyinput type="digit" v-model="formData.price" placeholder="请输入零售价" trim="all" /> |
|
|
<uni-easyinput type="digit" v-model="formData.price" placeholder="请输入零售价" trim="all" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="销售周期" name="salesWeek"> |
|
|
<uni-forms-item label="尾货预警" name="salesWeek" required> |
|
|
<!-- <uni-easyinput type="digit" v-model="formData.salesWeek" placeholder="请输入零售价" trim="all" /> --> |
|
|
<!-- <uni-easyinput type="digit" v-model="formData.salesWeek" placeholder="请输入零售价" trim="all" /> --> |
|
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="formData.salesWeek" /> |
|
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="formData.salesWeek" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="尾货预警" name="tailWarn" required> |
|
|
<uni-forms-item label="库存预警" name="tailWarn" required> |
|
|
<uni-easyinput type="digit" v-model="formData.tailWarn" placeholder="请设置尾货预警天数" trim="all" /> |
|
|
<uni-easyinput type="digit" v-model="formData.tailWarn" placeholder="请设置库存预警天数" trim="all" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="分类" name="categoryId" required> |
|
|
<uni-forms-item label="分类" name="categoryId" required> |
|
|
<uni-data-select class="uni-data-select" :localdata="categoryList" v-model="formData.categoryId" |
|
|
<uni-data-select class="uni-data-select" :localdata="categoryList" v-model="formData.categoryId" |
|
|
placeholder="请选择分类" @change="categoryChange"></uni-data-select> |
|
|
placeholder="请选择分类" @change="categoryChange"></uni-data-select> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<view class="attr"> |
|
|
|
|
|
<view class="content" v-for="(items,index) in arrtChange" :key="items.id"> |
|
|
|
|
|
<view class="attrName"> |
|
|
|
|
|
{{items.attributeName }} |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="attrs"> |
|
|
|
|
|
<text v-for="(itemTag, index1) in items.attrNameRange" :key="index1" |
|
|
|
|
|
@tap.stop="attrNameChange(index,index1) " |
|
|
|
|
|
:class="itemTag.isChecked ? 'checkedText' : '' "> {{itemTag.text}}</text> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<uni-forms-item label="货品简介" name="productIntro"> |
|
|
<uni-forms-item label="货品简介" name="productIntro"> |
|
|
<uni-easyinput type="textarea" autoHeight v-model="formData.productIntro" placeholder="请输入货品简介" |
|
|
<uni-easyinput type="textarea" autoHeight v-model="formData.productIntro" placeholder="请输入货品简介" |
|
|
trim="all" /> |
|
|
trim="all" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<!-- <uni-forms-item label="库存数量" name="name"> |
|
|
|
|
|
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入库存数量" trim="all"/> |
|
|
|
|
|
</uni-forms-item> --> |
|
|
|
|
|
<!-- <uni-forms-item label="上架日期" name="name"> |
|
|
|
|
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="formData.single" @maskClick="maskClick" /> |
|
|
|
|
|
</uni-forms-item> --> |
|
|
|
|
|
<!-- <uni-forms-item label="销售周期" name="name"> |
|
|
|
|
|
<uni-data-select |
|
|
|
|
|
class="uni-data-select" |
|
|
|
|
|
:localdata="range" |
|
|
|
|
|
v-model="formData.manufacturer" |
|
|
|
|
|
placeholder="请选择销售周期" |
|
|
|
|
|
></uni-data-select> |
|
|
|
|
|
</uni-forms-item> --> |
|
|
|
|
|
</uni-forms> |
|
|
</uni-forms> |
|
|
|
|
|
|
|
|
<u-button type="primary" @tap.stop="submit(ret)">保存</u-button> |
|
|
<u-button type="primary" @tap.stop="submit(ret)">保存</u-button> |
|
|
@ -88,22 +52,22 @@ |
|
|
fileList1: [], |
|
|
fileList1: [], |
|
|
// 表单数据 |
|
|
// 表单数据 |
|
|
formData: { |
|
|
formData: { |
|
|
name: '', |
|
|
productName: '', |
|
|
manufacturer: '', |
|
|
|
|
|
price: '', |
|
|
price: '', |
|
|
single: '', |
|
|
productSn:'', |
|
|
classification: '', |
|
|
wholesalePrice:'', |
|
|
// domains 字段下会有多个结果 |
|
|
// classification: '', |
|
|
domains: {}, |
|
|
productPicture: [], |
|
|
productPicture: [] |
|
|
productIntro:'', |
|
|
|
|
|
categoryId:'', |
|
|
|
|
|
salesWeek:'', |
|
|
|
|
|
tailWarn:'' |
|
|
}, |
|
|
}, |
|
|
categoryList: [], |
|
|
categoryList: [], |
|
|
arrtList: [], |
|
|
arrtList: [], |
|
|
arrtChange: [], |
|
|
arrtChange: [], |
|
|
bufferData: '', |
|
|
bufferData: '', |
|
|
attributeList: {}, |
|
|
|
|
|
rules: { |
|
|
rules: { |
|
|
// 对name字段进行必填验证 |
|
|
|
|
|
categoryId: { |
|
|
categoryId: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
@ -122,37 +86,30 @@ |
|
|
errorMessage: '请填写批发价', |
|
|
errorMessage: '请填写批发价', |
|
|
}, ], |
|
|
}, ], |
|
|
}, |
|
|
}, |
|
|
purchasePrice: { |
|
|
productSn: { |
|
|
rules: [{ |
|
|
|
|
|
required: true, |
|
|
|
|
|
errorMessage: '请填写采购价', |
|
|
|
|
|
}, ], |
|
|
|
|
|
}, |
|
|
|
|
|
barcode: { |
|
|
|
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请填写条码', |
|
|
errorMessage: '请填写货号', |
|
|
}, ], |
|
|
}, ], |
|
|
}, |
|
|
}, |
|
|
productSn: { |
|
|
productName: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请填写货号', |
|
|
errorMessage: '请填写商品名称', |
|
|
}, ], |
|
|
}, ], |
|
|
}, |
|
|
}, |
|
|
supplierId: { |
|
|
tailWarn: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请填写姓名', |
|
|
errorMessage: '请填写库存预警天数', |
|
|
}, ], |
|
|
}, ], |
|
|
}, |
|
|
}, |
|
|
productName: { |
|
|
salesWeek: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请填写商品名称', |
|
|
errorMessage: '请选择尾货预警天数', |
|
|
}, ], |
|
|
}, ], |
|
|
}, |
|
|
} |
|
|
fileList1: [], |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -217,8 +174,7 @@ |
|
|
console.log(url); |
|
|
console.log(url); |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
let a = uni.uploadFile({ |
|
|
let a = uni.uploadFile({ |
|
|
url: 'https://storage.xenjoyou.com/hiver/upload/file', // 仅为示例,非真实的接口地址 |
|
|
url: 'https://storage.xenjoyou.com/hiver/upload/file', |
|
|
// https://unidemo.dcloud.net.cn/upload |
|
|
|
|
|
filePath: url, |
|
|
filePath: url, |
|
|
name: 'file', |
|
|
name: 'file', |
|
|
header: { |
|
|
header: { |
|
|
@ -227,94 +183,22 @@ |
|
|
}, |
|
|
}, |
|
|
formData: {}, |
|
|
formData: {}, |
|
|
success: (uploadFileRes) => { |
|
|
success: (uploadFileRes) => { |
|
|
console.log('uploadFileRes', JSON.parse(uploadFileRes.data)); |
|
|
|
|
|
let path = JSON.parse(uploadFileRes.data) |
|
|
|
|
|
//后端返回的地址,存入图片地址 |
|
|
//后端返回的地址,存入图片地址 |
|
|
this.imageValue.push({ |
|
|
this.formData.productPicture.push({ |
|
|
url: this.imgURL + path.imgUrl, |
|
|
url: uploadFileRes.result, |
|
|
name: '' |
|
|
name: '' |
|
|
}) |
|
|
}) |
|
|
console.log('imageValue', this.imageValue) |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
attrNameChange(index, index1) { |
|
|
|
|
|
if (!this.arrtList[index].attrNameRange[index1].isChecked) this.arrtList[index].attrNameRange[index1] |
|
|
|
|
|
.isChecked = false |
|
|
|
|
|
this.arrtList[index].attrNameRange[index1].isChecked = this.arrtList[index].attrNameRange[index1] |
|
|
|
|
|
.isChecked ? false : true; |
|
|
|
|
|
this.arrtChange = JSON.parse(JSON.stringify(this.arrtList)); |
|
|
|
|
|
}, |
|
|
|
|
|
categoryChange(e) { |
|
|
categoryChange(e) { |
|
|
this.tui.request("/app/productAttribute/selectByCategoryId", "get", { |
|
|
|
|
|
categoryId: e |
|
|
|
|
|
}, false, true).then((res) => { |
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
this.arrtList = res.result; |
|
|
|
|
|
if (this.arrtList.length > 0) { |
|
|
|
|
|
this.arrtList.forEach((items) => { |
|
|
|
|
|
console.log(items, 'items'); |
|
|
|
|
|
this.tui.request("/app/productAttributeValue/selectByAttributeId", "get", { |
|
|
|
|
|
id: items.id |
|
|
|
|
|
}, false, true).then((res1) => { |
|
|
|
|
|
if (res1.code == 200) { |
|
|
|
|
|
items.attrNameRange = res1.result.map(val => { |
|
|
|
|
|
return { |
|
|
|
|
|
text: val.value, |
|
|
|
|
|
value: val.id |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.tui.toast(res.message) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
}) |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
this.arrtChange = this.arrtList |
|
|
|
|
|
}, 500) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
this.tui.toast(res.message) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
}, |
|
|
* 复写 binddata 方法,如果只是为了校验,无复杂自定义操作,可忽略此方法 |
|
|
|
|
|
* @param {String} name 字段名称 |
|
|
|
|
|
* @param {String} value 表单域的值 |
|
|
|
|
|
*/ |
|
|
|
|
|
// binddata(name,value){ |
|
|
|
|
|
// 通过 input 事件设置表单指定 name 的值 |
|
|
|
|
|
// this.$refs.form.setValue(name, value) |
|
|
|
|
|
// }, |
|
|
|
|
|
// 触发提交表单 |
|
|
// 触发提交表单 |
|
|
submit() { |
|
|
submit() { |
|
|
this.arrtList.forEach((item, index) => { |
|
|
|
|
|
item.value = []; |
|
|
|
|
|
item.attrNameRange.forEach((item2, index2) => { |
|
|
|
|
|
if (item2.isChecked) { |
|
|
|
|
|
item.value.push(item2.text) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
this.attributeList = this.arrtList.reduce((obj, item) => ({ |
|
|
|
|
|
...obj, |
|
|
|
|
|
[item.attributeName]: item.value |
|
|
|
|
|
}), {}) |
|
|
|
|
|
for (let val in this.attributeList) { |
|
|
|
|
|
if (this.attributeList[val].length == 0) { |
|
|
|
|
|
return uni.showToast({ |
|
|
|
|
|
title: "请添加属性", |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.$refs.form.validate().then(res => { |
|
|
this.$refs.form.validate().then(res => { |
|
|
res.attributeList = JSON.stringify(this.attributeList); |
|
|
this.tui.request("/app/product/save", "post", res, false, false).then((res1) => { |
|
|
|
|
|
|
|
|
this.tui.request("/app/product/save", "post", res, false, true).then((res1) => { |
|
|
|
|
|
if (res1.code == 200) { |
|
|
if (res1.code == 200) { |
|
|
uni.navigateBack({ |
|
|
uni.navigateBack({ |
|
|
delta: 1 |
|
|
delta: 1 |
|
|
@ -331,14 +215,6 @@ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
onPrint(opt) { |
|
|
onPrint(opt) { |
|
|
/** |
|
|
|
|
|
* 打印文字 addCPCLText |
|
|
|
|
|
* x: 文字方块左上角X座标,单位dot |
|
|
|
|
|
* y: 文字方块左上角Y座标,单位dot |
|
|
|
|
|
* fontName,fontSize: 字体,取值: 參考文檔 |
|
|
|
|
|
* rotation: 旋转 1-90度 2-180度 3-270度 其他-不旋转 |
|
|
|
|
|
* content: 文字内容 |
|
|
|
|
|
*/ |
|
|
|
|
|
//快递单600*1040 入库单440*320 |
|
|
//快递单600*1040 入库单440*320 |
|
|
let strCmd = blesdk.CreatCPCLPage(440, 320, 1, 0); |
|
|
let strCmd = blesdk.CreatCPCLPage(440, 320, 1, 0); |
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, '商品名:女装小西裤') |
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, '商品名:女装小西裤') |
|
|
|