|
|
@@ -0,0 +1,564 @@
|
|
|
+import { mapGetters, mapActions } from "vuex";
|
|
|
+import { copyObject } from "@/utils/util"
|
|
|
+import { allProduct } from '@/api/product'
|
|
|
+import { getMenu } from "@/api/item-class";
|
|
|
+import { getItemList } from '@/api/item';
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ selectJobType: "bill",//业务类型,开单、采购、损耗、盘点
|
|
|
+ selectJobId:0,//业务类型对应的主体ID等
|
|
|
+ isCut:false,
|
|
|
+ productInfoList: [], //商品信息
|
|
|
+ globalClassIndex: 0, //当前商品类别下标
|
|
|
+ py: "", //拼音搜索条件
|
|
|
+ type: "", //库存预警时,固定为waring,其他情况不传或者传空
|
|
|
+ autoLoad: true, //自动获取商品信息
|
|
|
+ allFilterProductInfo:'',
|
|
|
+ top_list:'',
|
|
|
+ scroll_into_view:"",
|
|
|
+ timeFun:"",
|
|
|
+ kdType:'HIT',//点击和扫码开单,HIT SCAN
|
|
|
+ globalCheckStock:true,// 考虑库存,盘点不需要考虑库存
|
|
|
+ isAddModel:false,
|
|
|
+ isAddInputFocus:false,
|
|
|
+ customData: { bigCount: 0, smallCount: 0, userPrice: 0,aboutPrice:0,totalPrice:0,remark:'',assignSeat:1},
|
|
|
+ globalItemList:[],
|
|
|
+ globalUnitType:0,
|
|
|
+ globalAllProduct:[],
|
|
|
+ calc:'add',
|
|
|
+ globalRequestType:'kd',
|
|
|
+ globalCustomId:0,
|
|
|
+ globalClassData:[],
|
|
|
+ globalClassId:0,
|
|
|
+ globalClassDataIndex:[],
|
|
|
+ globalFinishGetItem:0,
|
|
|
+ globalPage:1,
|
|
|
+ globalPy:'',
|
|
|
+ globalItemData:[],
|
|
|
+ globalScrollTopPlace:0,
|
|
|
+ globalScrollTopOldPlace:0,
|
|
|
+ globalIsRequesting:false,
|
|
|
+ globalCgMyCharge:0,
|
|
|
+ globalLookStock:0
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ const { selectJobType } = options;
|
|
|
+ if (selectJobType) {
|
|
|
+ this.selectJobType = selectJobType;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onUnload() {},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["getSelectInfo"]),
|
|
|
+ selectList() {
|
|
|
+ let selectInfo = this.getSelectInfo;
|
|
|
+ return selectInfo[this.selectJobType+'_'+this.selectJobId] || []
|
|
|
+ },
|
|
|
+ scrollClassId() {
|
|
|
+ const curClass = this.productInfoList[this.globalClassIndex];
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initData() {
|
|
|
+ let that = this
|
|
|
+ getMenu().then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.globalClassData = res.data.class ? res.data.class : []
|
|
|
+ that.globalClassDataIndex = res.data.classIndex ? res.data.classIndex : []
|
|
|
+ if(that.globalClassData[0]){
|
|
|
+ that.globalClassId = that.globalClassData[0].id
|
|
|
+ //保存到仓库
|
|
|
+ let currentInfo = uni.getStorageSync('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
|
|
|
+ if(!that.$util.isEmpty(currentInfo)){
|
|
|
+ that.setSelectInfo({ selectJobType: that.selectJobType, info: currentInfo,selectJobId:that.selectJobId })
|
|
|
+ }
|
|
|
+ that.getGlobalProductList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reGetGlobalProductList(){
|
|
|
+ this.globalGoToTop()
|
|
|
+ this.globalPage = 1
|
|
|
+ this.globalFinishGetItem = 0
|
|
|
+ this.getGlobalProductList()
|
|
|
+ },
|
|
|
+ getGlobalProductList(){
|
|
|
+ if(this.globalFinishGetItem == 1){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let that = this
|
|
|
+ getItemList({classId:this.globalClassId,requestType:this.globalRequestType,page:this.globalPage,
|
|
|
+ search:this.globalPy,customId:this.globalCustomId,globalCgMyCharge:this.globalCgMyCharge,lookStock:this.globalLookStock}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.globalItemData = that.globalPage == 1 ? res.data.list : that.globalItemData.concat(res.data.list)
|
|
|
+ if(res.data.moreData == 1){
|
|
|
+ that.globalPage++
|
|
|
+ }else{
|
|
|
+ that.globalFinishGetItem = 1
|
|
|
+ }
|
|
|
+ that.globalIsRequesting = false
|
|
|
+ that.globalRememberRefresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ sorts_fun(arr) {
|
|
|
+ return function(a, b) {
|
|
|
+ var v1 = a[arr];
|
|
|
+ var v2 = b[arr];
|
|
|
+ return v1 - v2;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ globalRememberRefresh(){
|
|
|
+ let that = this
|
|
|
+ if(that.$util.isEmpty(that.globalItemData)){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let selectListData = []
|
|
|
+ if(!that.$util.isEmpty(that.selectList)){
|
|
|
+ that.selectList.forEach((i)=>{
|
|
|
+ selectListData[i.id] = i
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //修改数据需要复制一份,否则不会生效
|
|
|
+ that.globalItemData = copyObject(that.globalItemData);
|
|
|
+
|
|
|
+ that.globalItemData = that.globalItemData.sort(this.sorts_fun('classId'))
|
|
|
+ let hasExists = []
|
|
|
+ for (let i=0;i<that.globalItemData.length;i++){
|
|
|
+ let currentProduct = that.globalItemData[i]
|
|
|
+ let currentPId = currentProduct.id
|
|
|
+ let currentClassId = currentProduct.classId||0
|
|
|
+ let selectProduct = selectListData[currentPId] || []
|
|
|
+ if(!that.$util.isEmpty(selectProduct)){
|
|
|
+ that.globalItemData[i].bigCount = selectProduct.bigCount || 0
|
|
|
+ that.globalItemData[i].userPrice = selectProduct.userPrice || 0
|
|
|
+ that.globalItemData[i].smallCount = selectProduct.smallCount || 0
|
|
|
+ that.globalItemData[i].totalPrice = selectProduct.totalPrice || 0
|
|
|
+ that.globalItemData[i].aboutPrice = selectProduct.aboutPrice || 0
|
|
|
+ that.globalItemData[i].remark = selectProduct.remark || ''
|
|
|
+ that.globalItemData[i].assignSeat = selectProduct.assignSeat
|
|
|
+ }else{
|
|
|
+ that.globalItemData[i].bigCount = 0
|
|
|
+ that.globalItemData[i].userPrice = 0
|
|
|
+ that.globalItemData[i].smallCount = 0
|
|
|
+ that.globalItemData[i].totalPrice = 0
|
|
|
+ that.globalItemData[i].aboutPrice = 0
|
|
|
+ that.globalItemData[i].remark = ''
|
|
|
+ that.globalItemData[i].assignSeat = 1
|
|
|
+ }
|
|
|
+ let cName = ''
|
|
|
+ if(hasExists[currentClassId]){
|
|
|
+ //无操作
|
|
|
+ }else{
|
|
|
+ let currentClass = this.globalClassDataIndex[currentClassId] ? this.globalClassDataIndex[currentClassId] : null
|
|
|
+ cName = currentClass.name ? currentClass.name : ''
|
|
|
+ hasExists[currentClassId] = 1
|
|
|
+ }
|
|
|
+ that.globalItemData[i].className = cName
|
|
|
+ }
|
|
|
+ },
|
|
|
+ globalSwitchClass(cur,item) {
|
|
|
+ this.globalGoToTop()
|
|
|
+ this.globalClassIndex = cur
|
|
|
+ this.globalPage = 1
|
|
|
+ this.globalPy = ''
|
|
|
+ this.$refs.globalSearchRef.search = ''
|
|
|
+ this.globalClassId = item.id
|
|
|
+ this.globalFinishGetItem = 0
|
|
|
+ this.getGlobalProductList()
|
|
|
+ },
|
|
|
+ pushToSave(selectData){
|
|
|
+ this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
|
|
|
+ uni.setStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId, selectData)
|
|
|
+ },
|
|
|
+ globalChangeClass(index,item){
|
|
|
+ this.$refs.globalClassImgRef.close()
|
|
|
+ this.globalSwitchClass(index,item)
|
|
|
+ },
|
|
|
+ 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})
|
|
|
+ //删除多颜色
|
|
|
+ if(that.selectJobType == 'bill'){
|
|
|
+ uni.removeStorageSync("xj"+that.selectJobId)
|
|
|
+ }
|
|
|
+ //删除显示
|
|
|
+ if(!this.$util.isEmpty(this.globalItemData)){
|
|
|
+ this.globalItemData.forEach((item,index,arr) =>{
|
|
|
+ arr[index].bigCount = 0;
|
|
|
+ arr[index].smallCount = 0;
|
|
|
+ arr[index].userPrice = 0;
|
|
|
+ arr[index].remark = '';
|
|
|
+ arr[index].assignSeat = 1
|
|
|
+ })
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ globalSearch(){
|
|
|
+ this.globalPage = 1
|
|
|
+ if(!this.$util.isEmpty(this.globalPy)){
|
|
|
+ this.globalGoToTop()
|
|
|
+ this.globalClassIndex = -1
|
|
|
+ this.globalFinishGetItem = 0
|
|
|
+ this.getGlobalProductList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ globalGoToTop(){
|
|
|
+ let that = this
|
|
|
+ this.globalScrollTopPlace = this.globalScrollTopOldPlace
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ that.globalScrollTopPlace = 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+ globalGetScroll(event){
|
|
|
+ this.globalScrollTopOldPlace = event.detail.scrollTop
|
|
|
+ },
|
|
|
+ globalScrollBottom(){
|
|
|
+ if(this.globalIsRequesting == true){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.globalIsRequesting = true
|
|
|
+ this.getGlobalProductList()
|
|
|
+ },
|
|
|
+ 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.globalCheckStock){
|
|
|
+ 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)
|
|
|
+ if (Number(currentCount) > Number(currentNum)) {
|
|
|
+ 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
|
|
|
+ list[index].aboutPrice = item.aboutPrice||0
|
|
|
+ list[index].totalPrice = item.totalPrice||0
|
|
|
+ list[index].remark = item.remark||''
|
|
|
+ list[index].assignSeat = item.assignSeat
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //点击要响声
|
|
|
+ if(this.kdType == 'HIT' && multiple ==0){
|
|
|
+ this.$util.hitRemind()
|
|
|
+ }
|
|
|
+ //扫码要响声
|
|
|
+ if(scan == 1){
|
|
|
+ this.$util.hitRemind()
|
|
|
+ }
|
|
|
+ //数据放到仓库
|
|
|
+ this.pushToSave(list)
|
|
|
+ this.globalRememberRefresh()
|
|
|
+ },
|
|
|
+ delSelectedItem(product){
|
|
|
+ let item = copyObject(product)
|
|
|
+ const list = this.selectList
|
|
|
+ let index = list.findIndex(element => element.id == item.id)
|
|
|
+ if(index != -1){
|
|
|
+ list.splice(index,1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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.globalCheckStock){
|
|
|
+ this.$util.noStockRemind()
|
|
|
+ this.$msg('库存不足哦..')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //弹框时默认显示的单位
|
|
|
+ if(Number(info.smallCount)>0){
|
|
|
+ this.globalUnitType = 1
|
|
|
+ this.cgUnitType = 1
|
|
|
+ }else{
|
|
|
+ this.globalUnitType = 0
|
|
|
+ this.cgUnitType = 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)
|
|
|
+ }
|
|
|
+ if(this.selectJobType == 'purchase'){
|
|
|
+ this.customData.totalPrice = this.customData.totalPrice ? Number(this.customData.totalPrice) : null
|
|
|
+ this.customData.aboutPrice = this.customData.aboutPrice||0
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.selectJobType == 'purchase'){
|
|
|
+ if(this.customData.aboutPrice == 1){
|
|
|
+ if(Number(this.customData.totalPrice)<=0){
|
|
|
+ uni.showToast({title:"请填写总金额"+this.customData.totalPrice,icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.totalPrice) == false){
|
|
|
+ uni.showToast({title:"请填写总金额哦",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.replaceItemFn(this.customData,1)
|
|
|
+ this.addItemModelHidden()
|
|
|
+ },
|
|
|
+ addItemModelHidden() {
|
|
|
+ this.isAddModel = false;
|
|
|
+ this.customData = {};
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|