|
|
@@ -1,730 +1,29 @@
|
|
|
-import { getProductDataApi,getStockInItem } from "@/api/product";
|
|
|
import { mapGetters, mapActions } from "vuex";
|
|
|
import { copyObject } from "@/utils/util"
|
|
|
-import { allProduct } from '@/api/product'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- selectJobType: "bill",//业务类型,开单、采购、损耗、盘点
|
|
|
- selectJobId:0,//业务类型对应的主体ID等
|
|
|
- isCut:false,
|
|
|
- productInfoList: [], //商品信息
|
|
|
- classIndex: 0, //当前商品类别下标
|
|
|
- py: "", //拼音搜索条件
|
|
|
- type: "", //库存预警时,固定为waring,其他情况不传或者传空
|
|
|
- autoLoad: true, //自动获取商品信息
|
|
|
- allFilterProductInfo:'',
|
|
|
- globalClassItemList:'',
|
|
|
- top_list:'',
|
|
|
- //id动态切换
|
|
|
- scroll_into_view:"",
|
|
|
- timeFun:"",
|
|
|
- kdType:'HIT',//点击和扫码开单,HIT SCAN
|
|
|
- checkStock:true,// 考虑库存,盘点不需要考虑库存
|
|
|
- isAddModel:false,
|
|
|
- isAddInputFocus:false,
|
|
|
- customData: { bigCount: 0, smallCount: 0, userPrice: 0 },
|
|
|
- globalItemList:[],
|
|
|
- //当前页面默认使用的单位 0大单位 1小单位
|
|
|
- globalUnitType:0,
|
|
|
- globalAllProduct:[],
|
|
|
- calc:'add'
|
|
|
- };
|
|
|
- },
|
|
|
- onLoad(options) {
|
|
|
- const { selectJobType } = options;
|
|
|
- if (selectJobType) {
|
|
|
- this.selectJobType = selectJobType;
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
- onUnload() {},
|
|
|
+ onLoad() {
|
|
|
+
|
|
|
+ },
|
|
|
+ onUnload(){
|
|
|
+
|
|
|
+ },
|
|
|
computed: {
|
|
|
- ...mapGetters(["getSelectInfo"]),
|
|
|
- //当前页面选中的商品列表
|
|
|
- selectList() {
|
|
|
- let selectInfo = this.getSelectInfo;
|
|
|
- return selectInfo[this.selectJobType+'_'+this.selectJobId] || []
|
|
|
- },
|
|
|
- scrollClassId() {
|
|
|
- const curClass = this.productInfoList[this.classIndex];
|
|
|
- if (curClass) {
|
|
|
- return `class_${curClass.classId}`;
|
|
|
- }
|
|
|
- return "";
|
|
|
- },
|
|
|
- allPrice() {
|
|
|
- let price = 0;
|
|
|
- if (this.selectList) {
|
|
|
- for (const item of this.selectList) {
|
|
|
- const itemInfo = this.getSelectItemById(item.id, item.classId);
|
|
|
- if (itemInfo && !this.$util.isEmpty(itemInfo.bigPrice) && !this.$util.isEmpty(itemInfo.smallPrice)) {
|
|
|
- if(item.userPrice>0){
|
|
|
- if(Number(item.bigCount) > 0){
|
|
|
- price += Number(item.bigCount) * Number(itemInfo.userPrice);
|
|
|
- }
|
|
|
- if(Number(item.smallCount) > 0){
|
|
|
- price += Number(item.smallCount) * Number(itemInfo.userPrice);
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(Number(item.bigCount) > 0){
|
|
|
- price += Number(item.bigCount) * Number(itemInfo.bigPrice);
|
|
|
- }
|
|
|
- if(Number(item.smallCount) > 0){
|
|
|
- price += Number(item.smallCount) * Number(itemInfo.smallPrice);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Math.round(price * 100) / 100;
|
|
|
- },
|
|
|
- //选择商品总数
|
|
|
- allCount() {
|
|
|
- let bigLength = 0;
|
|
|
- let smallLength = 0;
|
|
|
- let weight = 0
|
|
|
- if (this.selectList) {
|
|
|
- for (const item of this.selectList) {
|
|
|
- bigLength += Number(item.bigCount)
|
|
|
- smallLength += Number(item.smallCount)
|
|
|
- let thisWeight = item.weight ? item.weight : 0
|
|
|
- let currentWeight = Number(thisWeight)*Number(item.bigCount)
|
|
|
- weight = Number(weight) + Number(currentWeight)
|
|
|
- }
|
|
|
- weight = weight.toFixed(2)
|
|
|
- weight = parseFloat(weight)
|
|
|
- }
|
|
|
- return {bigLength:bigLength,smallLength:smallLength,weight:weight};
|
|
|
- },
|
|
|
- //当前选中商品列表中是否有没有库存的商品
|
|
|
- hasNoStock() {
|
|
|
- let has = false;
|
|
|
- if (this.selectList) {
|
|
|
- for (const item of this.selectList) {
|
|
|
- const {
|
|
|
- bigCount,
|
|
|
- smallCount,
|
|
|
- bigNum,
|
|
|
- smallNum,
|
|
|
- ratio
|
|
|
- } = item;
|
|
|
- const ratioNum = Number(ratio);
|
|
|
- if (
|
|
|
- Number(bigCount) * ratioNum + Number(smallCount) >
|
|
|
- Number(bigNum) * ratioNum + Number(smallNum)
|
|
|
- ) {
|
|
|
- has = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return has;
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
onShow(){
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions(["setSelectInfo", "reSetSelectInfo"]),
|
|
|
init(){
|
|
|
- if (this.autoLoad) {
|
|
|
- this.initData();
|
|
|
- }
|
|
|
- },
|
|
|
- //放到仓库
|
|
|
- pushToSave(selectData){
|
|
|
- this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
|
|
|
- uni.setStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId, selectData)
|
|
|
- },
|
|
|
- //询问是否删除缓存
|
|
|
- removeFromSave(){
|
|
|
- let that = this
|
|
|
- that.$util.confirmModal({content:'确认清除花材?'},() => {
|
|
|
- that.removeFromSaveDirect()
|
|
|
- that.$msg('已清除')
|
|
|
- })
|
|
|
- },
|
|
|
- //直接删除缓存
|
|
|
- removeFromSaveDirect(){
|
|
|
- let that = this
|
|
|
-
|
|
|
- uni.removeStorageSync('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
|
|
|
- that.reSetSelectInfo({selectJobType:that.selectJobType,selectJobId:that.selectJobId})
|
|
|
|
|
|
- //删除多颜色
|
|
|
- //console.log(that.selectJobType+that.selectJobId)
|
|
|
- if(that.selectJobType == 'bill'){
|
|
|
- uni.removeStorageSync("xj"+that.selectJobId)
|
|
|
- }
|
|
|
-
|
|
|
- if(!this.$util.isEmpty(this.globalClassItemList)){
|
|
|
- this.globalClassItemList.forEach((item,index,arr) =>{
|
|
|
- if(!this.$util.isEmpty(arr[index].child)){
|
|
|
- arr[index].child.forEach((ele,i,son)=>{
|
|
|
- arr[index].child[i].bigCount = 0;
|
|
|
- arr[index].child[i].smallCount = 0;
|
|
|
- arr[index].child[i].userPrice = 0;
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- this.$forceUpdate()
|
|
|
- }
|
|
|
- },
|
|
|
- //请求商品数据
|
|
|
- async initData(extendInfo) {
|
|
|
- let params = {type: this.type,customId:this.option.customId}
|
|
|
- if (extendInfo) {
|
|
|
- params = { ...params, ...extendInfo };
|
|
|
- }
|
|
|
- //区分获取正常花材和当天入库花材
|
|
|
- let hostFn = extendInfo && extendInfo.pdType && extendInfo.pdType == 'stockInPd' ? getStockInItem : getProductDataApi;
|
|
|
- const { data } = await hostFn(params);
|
|
|
- let currentClassItem = data.classItem ? data.classItem : []
|
|
|
- let currentItemList = data.itemList ? data.itemList : []
|
|
|
-
|
|
|
- this.globalItemList = currentItemList
|
|
|
-
|
|
|
- this.productInfoList = currentClassItem
|
|
|
-
|
|
|
- let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
|
|
|
- if(!this.$util.isEmpty(currentInfo)){
|
|
|
- this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
|
|
|
- }
|
|
|
- this.classIndex = 0;
|
|
|
- this.scroll_into_view = 'class_0';
|
|
|
- this.scrollPushList();
|
|
|
},
|
|
|
- //滚动或切换分类 获取更多数据
|
|
|
- scrollPushList(){
|
|
|
-
|
|
|
- //涉及记住花材的代码和流程,请全项目搜索关键词remember_item
|
|
|
- //将已选的花材按classId_productId键名组合
|
|
|
- let selectListData = []
|
|
|
- if(!this.$util.isEmpty(this.selectList)){
|
|
|
- this.selectList.forEach((i)=>{
|
|
|
- selectListData[i.id] = i
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- let list = copyObject(this.productInfoList);
|
|
|
- let classList = [];
|
|
|
- for (let i=0;i<list.length;i++){
|
|
|
-
|
|
|
- //将已选的花材数量和价格组合到总列表里
|
|
|
- if(!this.$util.isEmpty(list[i].child)){
|
|
|
- let currentChildren = list[i].child
|
|
|
- for(let x=0;x<currentChildren.length;x++){
|
|
|
- let currentProduct = currentChildren[x]
|
|
|
- let currentPId = currentProduct.id
|
|
|
- let selectProduct = selectListData[currentPId] || []
|
|
|
- if(!this.$util.isEmpty(selectProduct)){
|
|
|
- list[i].child[x].bigCount = selectProduct.bigCount || 0
|
|
|
- list[i].child[x].userPrice = selectProduct.userPrice || 0
|
|
|
- list[i].child[x].smallCount = selectProduct.smallCount || 0
|
|
|
- }else{
|
|
|
- list[i].child[x].bigCount = 0
|
|
|
- list[i].child[x].userPrice = 0
|
|
|
- list[i].child[x].smallCount = 0
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(i==0){
|
|
|
- classList.push({...list[i],isActive:true});
|
|
|
- }else if(i == 1){
|
|
|
- if(list[0].child && list[0].child.length >= 5){
|
|
|
- classList.push({...list[i],isActive:false});
|
|
|
- }else{
|
|
|
- classList.push({...list[i],isActive:true});
|
|
|
- }
|
|
|
- }else{
|
|
|
- classList.push({...list[i],isActive:false});
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- this.globalClassItemList = classList
|
|
|
- },
|
|
|
- //搜索对应花材
|
|
|
searchFn() {
|
|
|
- let list = this.globalItemList
|
|
|
- if(this.$util.isEmpty(this.py)){
|
|
|
- this.globalClassItemList = '';
|
|
|
- this.classIndex = 0;
|
|
|
- this.scroll_into_view = 'class_'+0;
|
|
|
- this.scrollPushList();
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- var reg = /^[0-9a-zA-Z]*$/g
|
|
|
- let notChinese = reg.test(this.py) == true ? true : false
|
|
|
-
|
|
|
- //大于等于2个字符才开始搜索 shish 20210622
|
|
|
- if(this.py.length <=1){
|
|
|
- return
|
|
|
- }
|
|
|
- //颜色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
|
|
|
- if(this.py.indexOf('fs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('粉色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('hs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('红色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('黄色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('zs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('紫色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('ls') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('绿色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('bs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('白色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('cs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('橙色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('银色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('yj') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- //涉及记住花材的代码和流程,请全项目搜索关键词remember_item
|
|
|
- //将已选的花材按productId键名组合
|
|
|
- let selectListData = []
|
|
|
- if(!this.$util.isEmpty(this.selectList)){
|
|
|
- this.selectList.forEach((i)=>{
|
|
|
- selectListData[i.id] = i
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- let filterItemData = [];
|
|
|
- list.forEach(currentItem => {
|
|
|
-
|
|
|
- //组合已记忆已选择的花材
|
|
|
- let currentPId = currentItem.id
|
|
|
- let selectProduct = selectListData[currentPId] || []
|
|
|
- if(!this.$util.isEmpty(selectProduct)){
|
|
|
- currentItem.bigCount = selectProduct.bigCount || 0
|
|
|
- currentItem.userPrice = selectProduct.userPrice || 0
|
|
|
- currentItem.smallCount = selectProduct.smallCount || 0
|
|
|
- }else{
|
|
|
- currentItem.bigCount = 0
|
|
|
- currentItem.userPrice = 0
|
|
|
- currentItem.smallCount = 0
|
|
|
- }
|
|
|
- let has = false
|
|
|
- if (notChinese){
|
|
|
- let elePy = (currentItem.py && currentItem.py.toLocaleUpperCase()) || "";
|
|
|
- has = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0 ? true : false
|
|
|
- }else{
|
|
|
- has = currentItem.name && currentItem.name.indexOf(this.py) >= 0 ? true : false
|
|
|
- }
|
|
|
- if (has) {
|
|
|
- if(this.$util.isEmpty(filterItemData)){
|
|
|
- filterItemData = [{classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]}]
|
|
|
- }else{
|
|
|
- filterItemData.forEach(res => {
|
|
|
- if(res.classId==currentItem.classId){
|
|
|
- res.child.push(currentItem)
|
|
|
- }else{
|
|
|
- filterItemData.push({classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]})
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
|
|
|
- let searchList = this.$util.unique(filterItemData)
|
|
|
- this.globalClassItemList = searchList;
|
|
|
- this.classIndex = 0;
|
|
|
- this.scroll_into_view = 'class_'+0;
|
|
|
- },
|
|
|
- //获取当前选中商品总价
|
|
|
- getSelectItemPrice(item) {
|
|
|
- let price = 0;
|
|
|
- const { bigCount, smallCount, bigPrice, smallPrice } = item;
|
|
|
- let sum =
|
|
|
- Number(bigCount) * Number(bigPrice) +
|
|
|
- Number(smallCount) * Number(smallPrice);
|
|
|
- price = Math.round(sum * 100) / 100;
|
|
|
- return price;
|
|
|
- },
|
|
|
- //通过id获取当前选中的商品信息
|
|
|
- getSelectItemById(id, classId) {
|
|
|
- let info = { bigCount: null, smallCount: null, autoPrice: null, itemPrice: null }
|
|
|
- const item = this.selectList && this.selectList.find(ele => { return ele.id == id && ele.classId == classId })
|
|
|
- if (item) {
|
|
|
- info = { ...item, bigCount: Number(item.bigCount), smallCount: Number(item.smallCount), autoPrice: Number(item.autoPrice), itemPrice: Number(item.itemPrice)}
|
|
|
- }
|
|
|
- return info;
|
|
|
- },
|
|
|
- //添加删除和修改花材
|
|
|
- //multiple 0一个一个加减 1弹框方式,多个加减
|
|
|
- //calc 当multiple=0时,add表示加,sub表示减
|
|
|
- replaceItemFn(product,multiple=0,calc='add',scan=0) {
|
|
|
- let item = copyObject(product)
|
|
|
- if(multiple == 0){
|
|
|
- if(Number(item.smallCount)>0){
|
|
|
- if(calc == 'add'){
|
|
|
- item.smallCount++
|
|
|
- }
|
|
|
- if(calc == 'sub'){
|
|
|
- item.smallCount--
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(calc == 'add'){
|
|
|
- item.bigCount++
|
|
|
- }
|
|
|
- if(calc == 'sub'){
|
|
|
- item.bigCount--
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const list = this.selectList
|
|
|
-
|
|
|
- let index = list.findIndex(element => element.id == item.id)
|
|
|
-
|
|
|
- //扫码数量累加
|
|
|
- if(index != -1 && scan == 1){
|
|
|
- item.bigCount = parseInt(Number(item.bigCount)+Number(list[index].bigCount))
|
|
|
- item.smallCount = parseInt(Number(item.smallCount)+Number(list[index].smallCount))
|
|
|
- }
|
|
|
-
|
|
|
- //扫码会出现负数
|
|
|
- if(Number(item.bigCount)<0 || Number(item.smallCount)<0){
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- if(this.checkStock){
|
|
|
- let currentCount = Number(item.bigCount) * item.ratio + Number(item.smallCount)
|
|
|
- currentCount = currentCount.toFixed(2)
|
|
|
- let currentNum = Number(item.bigNum) * item.ratio + Number(item.smallNum)
|
|
|
- currentNum = currentNum.toFixed(2)
|
|
|
- console.log(currentCount+' '+currentNum)
|
|
|
- if (Number(currentCount) > Number(currentNum)) {
|
|
|
- console.log('库存不足。。。')
|
|
|
- this.$util.noStockRemind()
|
|
|
- this.$msg("库存不足哦")
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(index == -1){
|
|
|
- if(this.$util.isEmpty(item.userPrice) || Number(item.userPrice) == 0){
|
|
|
- item.userPrice = item.bigPrice
|
|
|
- }
|
|
|
- list.push(item)
|
|
|
- }else{
|
|
|
- if(item.bigCount <= 0 && item.smallCount <= 0){
|
|
|
- //删除花材
|
|
|
- list.splice(index,1)
|
|
|
- }else{
|
|
|
- list[index].bigCount = item.bigCount
|
|
|
- list[index].smallCount = item.smallCount
|
|
|
- list[index].userPrice = item.userPrice
|
|
|
- }
|
|
|
- }
|
|
|
- //点击要响声
|
|
|
- if(this.kdType == 'HIT' && multiple ==0){
|
|
|
- this.$util.hitRemind()
|
|
|
- }
|
|
|
- //扫码要响声
|
|
|
- if(scan == 1){
|
|
|
- this.$util.hitRemind()
|
|
|
- }
|
|
|
-
|
|
|
- //数据放到仓库永久存放
|
|
|
- this.pushToSave(list)
|
|
|
-
|
|
|
- this.itemNumPriceRefresh()
|
|
|
-
|
|
|
-
|
|
|
- },
|
|
|
- listenScanItem(){
|
|
|
- let that = this
|
|
|
- // #ifdef APP-PLUS
|
|
|
- //避免重复,每次进来先移除全局自定义事件监听器
|
|
|
- uni.$off('listenGetScanCode')
|
|
|
- uni.$on('listenGetScanCode',function(data){
|
|
|
- that.takeItem(data.code)
|
|
|
- })
|
|
|
- // #endif
|
|
|
- allProduct().then(res=>{
|
|
|
- if(res.code == 1){
|
|
|
- that.globalAllProduct = res.data.list
|
|
|
- console.log('载入最新花材...')
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- takeItem(code){
|
|
|
- if(this.$util.isEmpty(code)){
|
|
|
- return false
|
|
|
- }
|
|
|
- let current = null
|
|
|
- let unitPrice = 0
|
|
|
- let unitName = ''
|
|
|
- //花材
|
|
|
- current = this.globalAllProduct.find(function(val){
|
|
|
- return Number(val.itemId) == Number(code)
|
|
|
- })
|
|
|
- if(current == undefined){
|
|
|
- return false
|
|
|
- }
|
|
|
- if(this.$util.isEmpty(current)){
|
|
|
- return false
|
|
|
- }
|
|
|
- unitName = current.bigUnit
|
|
|
- unitPrice = current.bigPrice
|
|
|
- let num = this.calc == 'add' ? 1 : -1
|
|
|
- let params = {...current,unitName:unitName,userPrice:unitPrice,bigCount:num,smallCount:0}
|
|
|
- this.replaceItemFn(params,1,'add',1)
|
|
|
- },
|
|
|
- //大小单位切换
|
|
|
- switchGlobalUnitType(){
|
|
|
- if(this.globalUnitType == 0){
|
|
|
- this.globalUnitType = 1
|
|
|
- this.customData.userPrice = parseFloat(this.customData.smallPrice)
|
|
|
- this.customData.bigCount = null
|
|
|
- }else{
|
|
|
- this.globalUnitType = 0
|
|
|
- this.customData.userPrice = parseFloat(this.customData.bigPrice)
|
|
|
- this.customData.smallCount = null
|
|
|
- }
|
|
|
- },
|
|
|
- //显示可以修改花材的弹框
|
|
|
- showAddModelFn(info) {
|
|
|
-
|
|
|
- if(info && info.variety == 1 && this.selectJobType == 'bill'){
|
|
|
- let curPage = getCurrentPages();
|
|
|
- let route = curPage[curPage.length - 1].route;
|
|
|
- if(route == 'admin/billing/affirm'){
|
|
|
- this.$msg('多颜色花材,请返回修改')
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(info.bigNum <= 0 && info.smallNum <= 0){
|
|
|
- if(this.checkStock){
|
|
|
- this.$util.noStockRemind()
|
|
|
- this.$msg('库存不足哦..')
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //弹框时默认显示的单位
|
|
|
- if(Number(info.smallCount)>0){
|
|
|
- this.globalUnitType = 1
|
|
|
- }else{
|
|
|
- this.globalUnitType = 0
|
|
|
- }
|
|
|
-
|
|
|
- this.isAddModel = true;
|
|
|
- this.customData = copyObject(info)
|
|
|
- this.isAddInputFocus = false;
|
|
|
- this.$nextTick(()=>{
|
|
|
- this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
|
|
|
- this.customData.bigCount = this.customData.bigCount==0?null:this.customData.bigCount;
|
|
|
- if(this.selectJobType == 'bill'){
|
|
|
- if(this.customData.userPrice == null || this.customData.userPrice == 0){
|
|
|
- this.customData.userPrice = parseFloat(this.customData.bigPrice)
|
|
|
- }
|
|
|
- }else{
|
|
|
- this.customData.userPrice = this.customData.userPrice==0 ? null : parseFloat(this.customData.userPrice)
|
|
|
- }
|
|
|
- this.isAddInputFocus = true;
|
|
|
- })
|
|
|
- },
|
|
|
- confirmAddItemModel(val) {
|
|
|
- if (val.index === 0) {
|
|
|
- this.addItemModelHidden();
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- //二个都不是数值
|
|
|
- if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
|
|
|
- uni.showToast({title:"请填写数值",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
|
|
|
- if(this.customData.bigCount<=0){
|
|
|
- uni.showToast({title:"数量要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
|
|
|
- if(this.customData.smallCount<=0){
|
|
|
- uni.showToast({title:"数量要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- //只有开单和采购需要使用价格
|
|
|
- if(this.selectJobType == 'bill' || this.selectJobType == 'purchase'){
|
|
|
- if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.userPrice) == false){
|
|
|
- uni.showToast({title:"金额错误",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- if(this.customData.userPrice <=0){
|
|
|
- uni.showToast({title:"金额要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- this.replaceItemFn(this.customData,1)
|
|
|
- this.addItemModelHidden()
|
|
|
- },
|
|
|
- addItemModelHidden() {
|
|
|
- this.isAddModel = false;
|
|
|
- this.customData = {};
|
|
|
- },
|
|
|
- itemNumPriceRefresh(){
|
|
|
- //涉及记住花材的代码和流程,请全项目搜索关键词remember_item
|
|
|
- //将已选的花材按classId_productId键名组合
|
|
|
- let selectListData = []
|
|
|
- if(!this.$util.isEmpty(this.selectList)){
|
|
|
- this.selectList.forEach((i)=>{
|
|
|
- selectListData[i.id] = i
|
|
|
- })
|
|
|
- }
|
|
|
- let upList = this.globalClassItemList;
|
|
|
- if(this.$util.isEmpty(upList)){
|
|
|
- return false
|
|
|
- }
|
|
|
- for (let i=0;i<upList.length;i++){
|
|
|
- //将已选的花材数量和价格组合到总列表里
|
|
|
- if(!this.$util.isEmpty(upList[i].child)){
|
|
|
- let currentChildren = upList[i].child
|
|
|
- for(let x=0;x<currentChildren.length;x++){
|
|
|
- let currentProduct = currentChildren[x]
|
|
|
- let currentPId = currentProduct.id
|
|
|
- let selectProduct = selectListData[currentPId] || []
|
|
|
- if(!this.$util.isEmpty(selectProduct)){
|
|
|
- upList[i].child[x].bigCount = selectProduct.bigCount || 0
|
|
|
- upList[i].child[x].userPrice = selectProduct.userPrice || 0
|
|
|
- upList[i].child[x].smallCount = selectProduct.smallCount || 0
|
|
|
- }else{
|
|
|
- upList[i].child[x].bigCount = 0
|
|
|
- upList[i].child[x].userPrice = 0
|
|
|
- upList[i].child[x].smallCount = 0
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //如果没用copyObject,在APP端搜索花材时,加花材数量不变化
|
|
|
- let o = copyObject(upList)
|
|
|
- this.globalClassItemList = o
|
|
|
- },
|
|
|
- //切换左侧商品类别
|
|
|
- swichClass(cur) {
|
|
|
- this.isCut = true;
|
|
|
- this.globalClassItemList[cur].isActive = true;
|
|
|
- if(cur==this.globalClassItemList.length-1){
|
|
|
- this.globalClassItemList[cur-1].isActive = true;
|
|
|
- }
|
|
|
- if(cur!=0&&cur!=this.globalClassItemList.length-1){
|
|
|
- this.globalClassItemList[cur-1].isActive = true;
|
|
|
- this.globalClassItemList[cur+1].isActive = true;
|
|
|
- if(this.globalClassItemList[cur+1].child.length<5 && cur<this.globalClassItemList.length-3){
|
|
|
- this.globalClassItemList[cur+2].isActive = true;
|
|
|
- }
|
|
|
- }
|
|
|
- this.scroll_into_view = '';
|
|
|
- this.$nextTick(()=>{
|
|
|
- this.scroll_into_view = 'class_'+cur;
|
|
|
- this.classIndex = cur;
|
|
|
- })
|
|
|
- //解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
|
|
|
- uni.setStorageSync("resolve","last");
|
|
|
- setTimeout(()=>{ uni.removeStorageSync("resolve") },400)
|
|
|
- },
|
|
|
- //滚动商品监听
|
|
|
- scroll_detail(options){
|
|
|
- if(this.isCut) {
|
|
|
- this.isCut = false
|
|
|
- return
|
|
|
- }
|
|
|
- //options为滚动信息,options.detail.scrollTop 值为相对于scroll-view。
|
|
|
- if(!uni.getStorageSync("resolve")){
|
|
|
- this.get_node_details(options);
|
|
|
- };
|
|
|
- },
|
|
|
- //获取商品节点信息
|
|
|
- get_node_details(options){
|
|
|
- //获得实例
|
|
|
- const query = uni.createSelectorQuery().in(this);
|
|
|
- //获取多个节点方式
|
|
|
- query.selectAll(".selectAll").boundingClientRect(data=>{
|
|
|
- this.top_list = data.map(item=>{
|
|
|
- return Math.ceil(item.top);
|
|
|
- });
|
|
|
- this.async_detail_msg(options);
|
|
|
- }).exec();
|
|
|
- },
|
|
|
- async_detail_msg(options){
|
|
|
- //options为滚动信息,options.detail.scrollTop 值为相对于scroll-view
|
|
|
- let top_page = options.detail.scrollTop + this.top_list[0];
|
|
|
- for(let i = 0;i < this.top_list.length; i++){
|
|
|
- let node1 = this.top_list[i];
|
|
|
- let node2 = this.top_list[i+1];
|
|
|
- if(node2 && top_page >= node1 && top_page < node2){
|
|
|
- this.classIndex = i;
|
|
|
- if(this.globalClassItemList[this.classIndex]){
|
|
|
- this.globalClassItemList[this.classIndex].isActive = true;
|
|
|
- }
|
|
|
- if(this.globalClassItemList[this.classIndex+1]){
|
|
|
- this.globalClassItemList[this.classIndex+1].isActive = true;
|
|
|
- }
|
|
|
- if(this.globalClassItemList[this.classIndex+1].child.length<5){
|
|
|
- if(this.globalClassItemList[this.classIndex+2]){
|
|
|
- this.globalClassItemList[this.classIndex+2].isActive = true;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }else if(node2 && top_page === node2){
|
|
|
- this.classIndex = i + 1;
|
|
|
- if(this.globalClassItemList[this.classIndex]){
|
|
|
- this.globalClassItemList[this.classIndex].isActive = true;
|
|
|
- }
|
|
|
- if(this.globalClassItemList[this.classIndex+1]){
|
|
|
- this.globalClassItemList[this.classIndex+1].isActive = true;
|
|
|
- }
|
|
|
- if(this.globalClassItemList[this.classIndex+1].child.length<5){
|
|
|
- if(this.globalClassItemList[this.classIndex+2]){
|
|
|
- this.globalClassItemList[this.classIndex+2].isActive = true;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- scroll_bottom(){
|
|
|
- this.classIndex = this.globalClassItemList.length-1
|
|
|
- this.globalClassItemList[this.classIndex].isActive = true;
|
|
|
- if(!this.$util.isEmpty(this.globalClassItemList[this.classIndex+1]) && this.globalClassItemList[this.classIndex+1].child.length<5){
|
|
|
- this.globalClassItemList[this.classIndex+2].isActive = true;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|