|
|
@@ -13,6 +13,9 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="分类" prop="category">
|
|
|
+ <el-input v-model="dataForm.category" style="width: 185px" />
|
|
|
+ </el-form-item>
|
|
|
<el-row>
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="正面" prop="frontUrl">
|
|
|
@@ -59,7 +62,9 @@ export default {
|
|
|
prodName: null,
|
|
|
seq: null,
|
|
|
isDelete: 0,
|
|
|
+ category:null
|
|
|
},
|
|
|
+ resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
|
|
|
prodList: [],
|
|
|
dataRule: {
|
|
|
}
|
|
|
@@ -90,10 +95,48 @@ export default {
|
|
|
if(item.prodId === prodId){
|
|
|
this.dataForm.prodName = item.prodName;
|
|
|
}
|
|
|
- })
|
|
|
- // this.dataForm.prodId = prod.value;
|
|
|
- // this.dataForm.prodName = prod.label;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getProdTypeSize(){
|
|
|
+ let width = 0;
|
|
|
+ let height = 0;
|
|
|
+ let prodName = this.dataForm.prodName;
|
|
|
+ if(prodName.indexOf('小卡') !== -1 || prodName.indexOf("仿拍立得") !== -1){
|
|
|
+ width = 709;
|
|
|
+ height = 1087;
|
|
|
+ }else if(prodName.indexOf("票根") !== -1){
|
|
|
+ width = 780;
|
|
|
+ height = 1489;
|
|
|
+ }else if(prodName.indexOf("圆形徽章") !== -1){
|
|
|
+ width = 850;
|
|
|
+ height = 850;
|
|
|
+ }else if(prodName.indexOf("明信片") !== -1){
|
|
|
+ width = 1252;
|
|
|
+ height = 1819;
|
|
|
+ }
|
|
|
+ return {width, height};
|
|
|
},
|
|
|
+ //验证图片尺寸
|
|
|
+ checkImageSize(imageStr, index) {
|
|
|
+ let width = this.getProdTypeSize().width;
|
|
|
+ let height = this.getProdTypeSize().height;
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let image = new Image();
|
|
|
+ image.onload = function() {
|
|
|
+ let imageFormat = imageStr.split('.').pop();
|
|
|
+ if(imageFormat !== 'jpg'){
|
|
|
+ reject(index);
|
|
|
+ }
|
|
|
+ if ((image.width === width && image.height === height)) {
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ reject(index);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ image.src = this.resourcesUrl + imageStr;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
getProdList(){
|
|
|
this.$http({
|
|
|
url: this.$http.adornUrl('/prod/prod/simpleList'),
|
|
|
@@ -104,26 +147,33 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 表单提交
|
|
|
- dataFormSubmit () {
|
|
|
- this.$refs['dataForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl('/print/printPicLib'),
|
|
|
- method: this.dataForm.id ? 'put' : 'post',
|
|
|
- data: this.$http.adornData(this.dataForm)
|
|
|
- }).then(({data}) => {
|
|
|
- this.$message({
|
|
|
- message: this.$i18n.t('publics.operation'),
|
|
|
- type: 'success',
|
|
|
- duration: 1500,
|
|
|
- onClose: () => {
|
|
|
- this.visible = false
|
|
|
- this.$emit('refreshDataList')
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
+ async dataFormSubmit () {
|
|
|
+ try{
|
|
|
+ let imgs = [];
|
|
|
+ imgs[0] = this.dataForm.frontUrl ? this.dataForm.frontUrl:null;
|
|
|
+ if(this.dataForm.backUrl){
|
|
|
+ imgs[1] = this.dataForm.backUrl ? this.dataForm.backUrl:null;
|
|
|
}
|
|
|
- })
|
|
|
+ await Promise.all(imgs.map(this.checkImageSize));
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl('/print/printPicLib'),
|
|
|
+ method: this.dataForm.id ? 'put' : 'post',
|
|
|
+ data: this.$http.adornData(this.dataForm)
|
|
|
+ }).then(({data}) => {
|
|
|
+ this.$message({
|
|
|
+ message: this.$i18n.t('publics.operation'),
|
|
|
+ type: 'success',
|
|
|
+ duration: 200,
|
|
|
+ onClose: () => {
|
|
|
+ this.visible = false
|
|
|
+ this.$emit('refreshDataList')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }catch (error) {
|
|
|
+ this.$message.error(`第 ${error + 1} 张图片不符合尺寸要求。`)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|