|
|
@@ -80,7 +80,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
- clear:false,
|
|
|
+ clear: false,
|
|
|
}, { //辅助单位标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("subUnitId"),
|
|
|
@@ -92,6 +92,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
+ readonly: true,
|
|
|
}, { //包装
|
|
|
code: 'packBox',
|
|
|
title: mixins.$t("package"),
|
|
|
@@ -99,6 +100,7 @@ Page({
|
|
|
sign: "",
|
|
|
digits: 0,
|
|
|
required: true,
|
|
|
+ readonly: true,
|
|
|
},
|
|
|
{
|
|
|
code: 'calculationFormula',
|
|
|
@@ -194,7 +196,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
- clear:false,
|
|
|
+ clear: false,
|
|
|
}, { //辅助单位标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("subUnitId"),
|
|
|
@@ -230,7 +232,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
- clear:false,
|
|
|
+ clear: false,
|
|
|
}, { //辅助单位标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("subUnitId"),
|
|
|
@@ -346,24 +348,27 @@ Page({
|
|
|
console.log("onShow");
|
|
|
this.dialogShowChooseData();
|
|
|
},
|
|
|
- /**
|
|
|
+ /**
|
|
|
* @desc : 因为chooseData 的执行顺序要高于onshow 且 chooseData无法弹 dialog 所以在onshow执行
|
|
|
* @date : 2024/2/1 15:49
|
|
|
* @author : 王英杰
|
|
|
*/
|
|
|
- dialogShowChooseData(){
|
|
|
- if(!this.data.handledata){
|
|
|
+ dialogShowChooseData() {
|
|
|
+ if (!this.data.handledata) {
|
|
|
return
|
|
|
}
|
|
|
this.setData({
|
|
|
- handledata:false
|
|
|
+ handledata: false
|
|
|
})
|
|
|
let formData = JSON.parse(this.data.formData)
|
|
|
let data = this.data.chooseUnitData
|
|
|
formData.intoQty = null
|
|
|
+ formData.packBox = null
|
|
|
+ formData.subUnitId = null
|
|
|
+ formData.subUnitName = null
|
|
|
//提示
|
|
|
Dialog.confirm({
|
|
|
- message: '期初数量已输入,更换基础单位需要清空期初数量',
|
|
|
+ message: '更换基础单位将清空包装单位,期初数量,包装数量',
|
|
|
}).then(() => {
|
|
|
this.handleChooseDataUnit(formData, data)
|
|
|
}).catch(() => {});
|
|
|
@@ -389,10 +394,10 @@ Page({
|
|
|
}
|
|
|
if (code == "unitId") { //计量单位
|
|
|
//当期初数量有值的时候 弹提示是否清除
|
|
|
- if (formData.intoQty) { //在onshow执行 这里无法弹出dialog
|
|
|
+ if (formData.intoQty || formData.packBox) { //在onshow执行 这里无法弹出dialog
|
|
|
this.setData({
|
|
|
- chooseUnitData:data,
|
|
|
- handledata:true
|
|
|
+ chooseUnitData: data,
|
|
|
+ handledata: true
|
|
|
})
|
|
|
} else {
|
|
|
this.handleChooseDataUnit(formData, data)
|
|
|
@@ -400,6 +405,12 @@ Page({
|
|
|
|
|
|
}
|
|
|
if (code == "subUnitId") { //辅助计量单位
|
|
|
+ if (data.id == formData.unitId) {
|
|
|
+ setTimeout(() => {
|
|
|
+ util.showToast('包装单位不能等于基本单位');
|
|
|
+ }, 1000)
|
|
|
+ return
|
|
|
+ }
|
|
|
formData.subUnitId = data.id
|
|
|
formData.subUnitName = data.name
|
|
|
if (formData.packBox && formData.unitName && formData.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
|
|
|
@@ -435,14 +446,31 @@ Page({
|
|
|
// 遍历 contentObj.warehouse 数组
|
|
|
for (let i = 0; i < contentObj.warehouse.length; i++) {
|
|
|
// 检查当前对象的 code 是否为 'intoQty'
|
|
|
- if (contentObj.warehouse[i].code === 'intoQty') {
|
|
|
+ if (contentObj.warehouse[i].code === 'intoQty') { //期初数量
|
|
|
// 如果是,则修改其 digits 属性
|
|
|
contentObj.warehouse[i].digits = formData.decimalPlaces;
|
|
|
+ contentObj.warehouse[i].readonly = false;
|
|
|
// 找到后,可以跳出循环(如果确定只有一个匹配项)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (contentObj.unit.length > 0) {
|
|
|
+ // 遍历 contentObj.unit 数组
|
|
|
+ for (let i = 0; i < contentObj.unit.length; i++) {
|
|
|
+ // 检查当前对象的 code 是否为 'packBox'
|
|
|
+ if (contentObj.unit[i].code === 'packBox') { //包装
|
|
|
+ // 如果是,则修改其 digits 属性
|
|
|
+ contentObj.unit[i].digits = formData.decimalPlaces;
|
|
|
+ contentObj.unit[i].readonly = false;
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if (contentObj.unit[i].code === 'subUnitId') { //包装单位
|
|
|
+ contentObj.unit[i].readonly = false;
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
this.setData({
|
|
|
contentObj: contentObj,
|
|
|
formData: JSON.stringify(formData)
|
|
|
@@ -508,14 +536,13 @@ Page({
|
|
|
// 增加包装;数字类型正整数,默认1
|
|
|
let formData = {}
|
|
|
let contentObj = this.data.contentObj
|
|
|
- formData.packBox = 1
|
|
|
formData.flgPrice = true
|
|
|
formData.flgOpeningInv = false
|
|
|
formData.flgSubUnit = true
|
|
|
-
|
|
|
+
|
|
|
that.setData({
|
|
|
formData: JSON.stringify(formData),
|
|
|
- loading:false,
|
|
|
+ loading: false,
|
|
|
contentObj: {
|
|
|
main: [{ //商品型号
|
|
|
code: 'skuModel',
|
|
|
@@ -531,7 +558,7 @@ Page({
|
|
|
name: mixins.$t("commodityPicture"), //商品图片
|
|
|
type: 'uploader',
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
],
|
|
|
goods: [{ //商品品牌
|
|
|
code: 'brandId',
|
|
|
@@ -548,15 +575,15 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'goodsCategory',
|
|
|
required: true,
|
|
|
-
|
|
|
+
|
|
|
}, { //商品系列
|
|
|
code: 'seriesId',
|
|
|
name: 'seriesName',
|
|
|
title: mixins.$t("goodsSeries"),
|
|
|
type: 'choose',
|
|
|
urlKey: 'goodsSeries',
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}, { //商品规格
|
|
|
code: 'skuSpec',
|
|
|
name: 'skuSpec',
|
|
|
@@ -572,7 +599,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
- clear:false,
|
|
|
+ clear: false,
|
|
|
}, { //辅助单位标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("subUnitId"),
|
|
|
@@ -584,6 +611,7 @@ Page({
|
|
|
type: 'choose',
|
|
|
urlKey: 'unit',
|
|
|
required: true,
|
|
|
+ readonly: true,
|
|
|
}, { //包装
|
|
|
code: 'packBox',
|
|
|
title: mixins.$t("package"),
|
|
|
@@ -591,6 +619,7 @@ Page({
|
|
|
sign: "",
|
|
|
digits: 0,
|
|
|
required: true,
|
|
|
+ readonly: true,
|
|
|
},
|
|
|
{
|
|
|
code: 'calculationFormula',
|
|
|
@@ -639,7 +668,7 @@ Page({
|
|
|
title: mixins.$t("otherPriceLimit"),
|
|
|
required: true,
|
|
|
}, ],
|
|
|
-
|
|
|
+
|
|
|
other: [{
|
|
|
code: 'remarks',
|
|
|
type: 'textarea',
|
|
|
@@ -657,7 +686,7 @@ Page({
|
|
|
* @author : 姜永辉
|
|
|
*/
|
|
|
handleSaveData() {
|
|
|
- console.log('eee',this.data.formType,this.data.formType == Constants.formType.shopping);
|
|
|
+ console.log('eee', this.data.formType, this.data.formType == Constants.formType.shopping);
|
|
|
//购物车跳转来的,新建完毕直接回到选择界面
|
|
|
if (this.data.formType == Constants.formType.shopping) {
|
|
|
// var pages = getCurrentPages();
|
|
|
@@ -702,8 +731,7 @@ Page({
|
|
|
} else {
|
|
|
// 增加包装;数字类型正整数,默认1
|
|
|
let formData = JSON.parse(this.data.formData) || {}
|
|
|
- console.log('eeee',formData,this.data.formData,this.data.formType);
|
|
|
- formData.packBox = 1
|
|
|
+ console.log('eeee', formData, this.data.formData, this.data.formType);
|
|
|
formData.flgPrice = true
|
|
|
formData.flgOpeningInv = false
|
|
|
formData.flgSubUnit = true
|
|
|
@@ -714,7 +742,7 @@ Page({
|
|
|
title: mixins.$t('addGoodsSuk'),
|
|
|
})
|
|
|
}
|
|
|
- console.log('dddddd',this.data.formType);
|
|
|
+ console.log('dddddd', this.data.formType);
|
|
|
},
|
|
|
/**
|
|
|
* @desc : 给表单赋值
|
|
|
@@ -725,8 +753,7 @@ Page({
|
|
|
// data.serviceCategories = (data.serviceCategories && data.serviceCategories.length > 0) ? data.serviceCategories.join(',') : undefined
|
|
|
data.annexPaths = data.skuImages
|
|
|
data.onlyCode = data.skuCode
|
|
|
- data.isflgOpeningInv = false //因为期初库存编辑的时候不让改 所以 即使数据库是true 那么也要置灰 取这个code
|
|
|
- data.isflgOpeningInv = false // 库存量不为0不让更改 辅助单位取这个code
|
|
|
+
|
|
|
let contentObj = this.data.contentObj
|
|
|
// 我们要添加的新对象是 编码 新建的时候没有 编辑的时候添加
|
|
|
contentObj.main = [{ //唯一编码
|
|
|
@@ -751,7 +778,11 @@ Page({
|
|
|
|
|
|
]
|
|
|
if (data.flgSubUnit) {
|
|
|
- contentObj.unit = [{ //基本单位
|
|
|
+ if(data.inventoryCount !== 0){
|
|
|
+ contentObj.unit = [{
|
|
|
+ text: '本商品有库存,不可更改单位模块;需全部出库后才可更改',
|
|
|
+ type: 'text',
|
|
|
+ },{ //基本单位
|
|
|
code: 'unitId',
|
|
|
name: 'unitName',
|
|
|
title: mixins.$t("unit"),
|
|
|
@@ -762,8 +793,48 @@ Page({
|
|
|
}, { //辅助单位标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("subUnitId"),
|
|
|
- code: (data.inventoryCount !== 0) ? 'isflgOpeningInv' : 'flgSubUnit',
|
|
|
+ code: 'flgSubUnit',
|
|
|
+ disabled:(data.inventoryCount !== 0),
|
|
|
+
|
|
|
+ }, { //包装单位
|
|
|
+ code: 'subUnitId',
|
|
|
+ name: 'subUnitName',
|
|
|
+ title: mixins.$t("packageUnit"),
|
|
|
+ type: 'choose',
|
|
|
+ urlKey: 'unit',
|
|
|
+ required: true,
|
|
|
+ readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
|
|
|
+ }, { //包装
|
|
|
+ code: 'packBox',
|
|
|
+ title: mixins.$t("package"),
|
|
|
+ type: 'number',
|
|
|
+ sign: "",
|
|
|
+ digits: 0,
|
|
|
+ required: true,
|
|
|
+ readonly: data.inventoryCount !== 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'calculationFormula',
|
|
|
+ type: 'textarea',
|
|
|
+ title: mixins.$t("calculationFormula"),
|
|
|
+ readonly: true,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }else{ //没库存
|
|
|
+ contentObj.unit = [{ //基本单位
|
|
|
+ code: 'unitId',
|
|
|
+ name: 'unitName',
|
|
|
+ title: mixins.$t("unit"),
|
|
|
+ type: 'choose',
|
|
|
+ urlKey: 'unit',
|
|
|
+ required: true,
|
|
|
readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
|
|
|
+ }, { //辅助单位标识
|
|
|
+ type: 'switch',
|
|
|
+ title: mixins.$t("subUnitId"),
|
|
|
+ code: 'flgSubUnit',
|
|
|
+ disabled:(data.inventoryCount !== 0),
|
|
|
+
|
|
|
}, { //包装单位
|
|
|
code: 'subUnitId',
|
|
|
name: 'subUnitName',
|
|
|
@@ -779,6 +850,7 @@ Page({
|
|
|
sign: "",
|
|
|
digits: 0,
|
|
|
required: true,
|
|
|
+ readonly: data.inventoryCount !== 0
|
|
|
},
|
|
|
{
|
|
|
code: 'calculationFormula',
|
|
|
@@ -787,6 +859,8 @@ Page({
|
|
|
readonly: true,
|
|
|
}
|
|
|
]
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
contentObj.unit = [{ //基本单位
|
|
|
code: 'unitId',
|
|
|
@@ -806,8 +880,9 @@ Page({
|
|
|
contentObj.warehouse = [{ //期初库存标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("openingInv"),
|
|
|
- code: 'isflgOpeningInv',
|
|
|
- readonly: true,
|
|
|
+ code: 'flgOpeningInv',
|
|
|
+ disabled: true,
|
|
|
+
|
|
|
}, { //仓库名称
|
|
|
code: 'whId',
|
|
|
name: 'whName',
|
|
|
@@ -846,8 +921,8 @@ Page({
|
|
|
contentObj.warehouse = [{ //期初库存标识
|
|
|
type: 'switch',
|
|
|
title: mixins.$t("openingInv"),
|
|
|
- code: 'isflgOpeningInv',
|
|
|
- readonly: true,
|
|
|
+ code: 'flgOpeningInv',
|
|
|
+ disabled: true,
|
|
|
}, ]
|
|
|
}
|
|
|
if (data.flgPrice) {
|