!! productList.length 和 productList.length的区别

!!productList.length 和 productList.length 在JavaScript中是不同的表达式,尽管它们都与数组或类数组对象的长度相关。

1、productList.length:

  • 这是一个直接访问 productList 数组或类数组对象的 length 属性的表达式。
  • 它返回一个数字,表示 productList 中的元素数量。
  • 如果 productList 是空数组,productList.length 返回 0。
  • 如果 productList 是一个未定义或空的类数组对象,productList.length 也可能是 undefined 或 0。

2、!!productList.length:

  • 这个表达式使用了双重否定运算符 !!。
  • !! 是一种将任何值转换为布尔值的技巧。它先将值转换为布尔值,再取反两次,最终返回 true 或 false。
  • 对于 productList.length,这个表达式的作用是:
    • 如果 productList.length 为 非零数值(如大于 0),!!productList.length 将返回 true。
    • 如果 productList.length 为 零,!!productList.length 将返回 false。
    • 如果 productList 未定义或没有 length 属性,productList.length 会导致错误,!!productList.length 同样会返回 false(因为 undefined 或其他假值转换为 false)。
let productList = [1, 2, 3];
console.log(productList.length);      // 输出: 3
console.log(!!productList.length);    // 输出: true

productList = [];
console.log(productList.length);      // 输出: 0
console.log(!!productList.length);    // 输出: false

productList = null;
console.log(productList.length);      // 错误: Cannot read property 'length' of null
console.log(!!productList.length);    // 错误: Cannot read property 'length' of null

3、总结:

productList.length 返回 productList 数组的长度(数字)。
!!productList.length 将该长度转换为布尔值,通常用于检查数组是否为空(即 length > 0)。

<tr v-if=" formitem.tableOne[index].AiList[i].productList.length > 0 " :key="`AiList-${index}-${i}`" > <td class="tdBackgrounds" colspan="2" :rowspan=" formitem.tableOne[index].AiList[i].productList.length " > <span>AI技术产品名称</span> </td> <td colspan="3"> <FormItem :label-width="0" :prop=" 'tableOne[' + index + '].AiList[' + i + '].productList' + 0 + '].descriptions' " :rules="{ required: true, message: '不能为空', trigger: 'change' }" > <PopInput type="textarea" :placeholder="'填写描述文字'" v-model=" formitem.tableOne[index].AiList[i].productList[0] .descriptions " class="nants" maxlength="500" :autosize="{ minRows: 1 }" /> </FormItem> </td> </tr> <template v-if=" formitem.tableOne[index].AiList[i].productList.length > 1 " v-for="(itm, indx) in formitem.tableOne[index].AiList[i] .productList" > <tr v-if="indx > 0" :key="indx + 'productList' + index + i" > <td colspan="3" :key="indx + 'productList' + index + i"> <FormItem :label-width="0" :prop=" 'tableOne[' + index + '].AiList[' + i + '].productList' + indx + '].descriptions' " :rules="{ required: true, message: '不能为空', trigger: 'change' }" > <PopInput type="textarea" :placeholder="'填写描述文字'" v-model=" formitem.tableOne[index].AiList[i].productList[ indx ].descriptions " class="nants" maxlength="500" :autosize="{ minRows: 1 }" /> </FormItem> </td> </tr> </template> <!-- <tr :key="indx + 'productList'"> </tr> --> <tr :key="i + 'AiList' + index + i"> <td colspan="5"> <AddButton v-if="!$route.query.youlook && !isDeadline" @click="addRow1('AiList', index, i, 'productList')" ></AddButton> </td> </tr>为什么descriptions不校验
最新发布
01-09
<template> <view class="contentAll" v-if="pageStatue==1"> <phoneHead></phoneHead> <view class="header" style="margin-top: -10rpx;"> <Headesnav :title='titleText' backText=""></Headesnav> </view> <view class="cardBox"> <view class="productInput" @click="showWarehouse=true"> <view class="productText"> <view class="left">入库仓库</view> </view> <view v-if="detailsStatus!=2" class="picker" style="margin-top: 6rpx;"> <view class="noData" v-if="warehouseIndex=='-1'"> 请选择仓库 </view> <view class="" v-else> {{warehouseList[warehouseIndex]}} </view> <uni-icons type="forward" size="16" color="#d8d8dc" style="padding-top: 6rpx;"></uni-icons> </view> <view v-else class="picker" style="margin-top: 6rpx;"> {{warehouseList[warehouseIndex]}} </view> </view> <view class="productInput" @click="showProductrRelevancy=true"> <view class="productText"> <view v-if="detailsStatus!=2" class="left productrRelevancy">经手人</view> <view v-else class="left">经手人</view> </view> <view v-if="detailsStatus!=2||shenheStatus==1" class="picker" style="margin-top: 6rpx;"> <view class="noData" v-if="productrRelevancyIndex=='-1'"> 请选择经手人 </view> <view class="" v-else> {{productrRelevancyList[productrRelevancyIndex]}} </view> <uni-icons type="forward" size="16" color="#d8d8dc" style="padding-top: 6rpx;"></uni-icons> </view> <view v-else class="picker" style="margin-top: 6rpx;"> {{productrRelevancyList[productrRelevancyIndex]}} </view> </view> <view class="productInput" @click="showTime=true"> <view class="productText"> <view class="left">业务日期</view> </view> <view v-if="detailsStatus!=2||shenheStatus==1" class="picker" style="margin-top: 6rpx;"> <view> {{defaultTime}} </view> <uni-icons type="forward" size="16" color="#d8d8dc" style="padding-top: 6rpx;"></uni-icons> </view> <view v-else class="picker" style="margin-top: 6rpx;"> {{defaultTime}} </view> </view> <view class="productInput" @click="showActionType=true"> <view class="productText"> <view class="left">操作类型</view> </view> <view v-if="detailsStatus!=2||shenheStatus==1" class="picker" style="margin-top: 6rpx;"> <view class="noData" v-if="actionTypeIndex=='-1'"> 请选择操作类型 </view> <view class="" v-else> {{actionTypeList[actionTypeIndex]}} </view> <uni-icons type="forward" size="16" color="#d8d8dc" style="padding-top: 6rpx;"></uni-icons> </view> <view v-else class="picker" style="margin-top: 6rpx;"> {{actionTypeList[actionTypeIndex]}} </view> </view> <view class="productInput"> <view class="productText"> <view class="left">备注</view> </view> <view v-if="detailsStatus!=2||shenheStatus==1" class="productImfor" style="margin-top: 6rpx;"> <input placeholder="请输入备注" v-model="query.memo" /> </view> <view v-else class="productImfor" style="margin-top: 6rpx;"> {{query.memo}} </view> </view> </view> <scroll-view :class="detailsStatus!=2||shenheStatus==1 ? 'scroll-Y' : 'scroll-Ys'" scroll-y="true"> <view class=""> <view class="" v-if="productList1.length>0"> <view class="product-card" v-for="(item,index) in productList1" :key="index"> <view class="cardTitle"> <view class="titleBoxs"> <view class="name" style="font-size: 36rpx;color: black;">{{item.Name}}</view> <view class="right" v-if="detailsStatus!=2||shenheStatus==1"> <button size="mini" type="warn" plain="true" @click="deleteList(item)">删除</button> </view> </view> </view> <view class="cardContent"> <view class="oneBox"> <view class="title">分类:</view> <view class="right"> {{item.ProductTypeName}} </view> </view> <view class="oneBox"> <view class="title">品牌:</view> <view class="right"> {{item.BrandName}} </view> </view> <view class="oneBox"> <view class="title">单位:</view> <view class="right"> {{item.StandardUnitName}} </view> </view> <view class="oneBox"> <view class="title">零售价:</view> <view class="right"> {{item.RetailPrice}} </view> </view> <view class="oneBox" style="margin-top: 10rpx;"> <view class="title">产品数量:</view> <view v-if="detailsStatus!=2||shenheStatus==1" class="priceInput"> <input placeholder="" v-model="item.productSum" type="number" @input="shuruSum($event,item)" /> </view> <view v-else class="right"> {{item.productSum}} </view> </view> <view class="oneBox" style="margin-top: 10rpx;" v-if="$store.getters.isPermission('40f127d9-5ffc-4e4f-8449-aacb182ddae4')"> <view class="title">成本价格:</view> <view v-if="detailsStatus!=2||shenheStatus==1" class="priceInput"> <input placeholder="" v-model="item.CostPrice" type="number" @input="shuruChengBenJia($event,item)" /> </view> <view v-else class="right"> {{item.CostPrice}} </view> </view> <view class="oneBox" style="margin-top: 10rpx;" v-if="$store.getters.isPermission('40f127d9-5ffc-4e4f-8449-aacb182ddae4')"> <view class="title">成本总额:</view> <view v-if="detailsStatus!=2||shenheStatus==1" class="priceInput"> <input placeholder="" v-model="item.chnegbenSumPrice" type="number" :disabled="true" /> </view> <view v-else class="right"> {{item.chnegbenSumPrice}} </view> </view> <view class="oneBox" style="margin-top: 10rpx;"> <view class="title">合计金额:</view> <view v-if="detailsStatus!=2||shenheStatus==1" class="priceInput"> <input placeholder="" v-model="item.hejiSumPrice" type="number" :disabled="true" /> </view> <view v-else class="right"> {{item.hejiSumPrice}} </view> </view> </view> </view> <view class="AllSum"> <view class="twoBox" style="color: #07c160;"> 合计数量:{{productList1.allQuatity}} </view> <view class="twoBox" style="margin-top: 8rpx; color: #2979ff;"> 合计金额:{{productList1.allPrice}} </view> <view class="twoBox" style=" color: red;" v-if="$store.getters.isPermission('40f127d9-5ffc-4e4f-8449-aacb182ddae4')"> 合计成本:{{productList1.allCostPrice}} </view> </view> </view> <view class="empty" v-else> <u-empty text="暂无产品" mode="list"></u-empty> </view> </view> </scroll-view> <!-- 删除提示 --> <view> <u-popup v-model="show1" mode="center" border-radius="14"> <view class="popupMax"> <view class="title" style="color: red;"> 请确认是否删除? </view> <view class="submit"> <view @click="show1=false" style="opacity: 0.8;">取消</view> <view style="color: #2979ff;" @click="confirmRemove">确定</view> </view> </view> </u-popup> </view> <!-- 审核提示 --> <view> <u-popup v-model="show2" mode="center" border-radius="14"> <view class="popupMax"> <view class="title" style="color: red;"> 是否入库? </view> <view class="submit"> <view @click="show2=false" style="opacity: 0.8;">取消</view> <view style="color: #2979ff;" @click="shenHeSubmit">确定</view> </view> </view> </u-popup> </view> <view v-for="(item,index) in scanList2" :key="index">{{item}}</view> <view class="scan" @click.passive="scanProduct" v-if="detailsStatus!=2||shenheStatus==1"> <view class="addText"> 扫码入库 </view> </view> <view class="zidingyixuanfu" @click.passive="showProduct" v-if="detailsStatus!=2||shenheStatus==1"> <view class="addText"> 浏览产品 </view> </view> <view class="submitAdd" v-if="shenheStatus==1"> <view class="cancel_button" @click="quxiao">返回</view> <view class="add_button" @click="show2=true">审核 </view> <view class="quxiao_button" @click="show3=true">撤销 </view> <view class="save_button" @click="baoCun">保存</view> </view> <view class="submitAdd2" v-if="shenheStatus!=5&&shenheStatus!=2&&shenheStatus!=1"> <view class="cancel_button" @click="quxiao">返回</view> <view class="save_button" @click="baoCun">保存</view> </view> <view class="submitAdd3" v-if="detailsStatus==2&&shenheStatus==2&&IsQuxiao==true"> <view class="cancel_button" @click="quxiao">返回</view> <view class="quxiao_button" @click="show4=true">撤销 </view> </view> <view class="submitAdd4" v-if="detailsStatus==2&&shenheStatus==2&&IsQuxiao==false"> <view class="cancel_button" @click="quxiao">返回</view> </view> <view class="submitAdd5" v-if="detailsStatus==2&&shenheStatus==5&&IsQuxiao==true"> <view class="cancel_button" @click="quxiao">返回</view> </view> <view> <u-popup v-model="show3" mode="center" border-radius="14"> <view class="popupMax"> <view class="title" style="color: red;"> 确认是否撤销单据? </view> <view class="submit"> <view @click="show3=false" style="opacity: 0.8;">取消</view> <view style="color: #2979ff;" @click="cheXiaoSubmit">确定</view> </view> </view> </u-popup> </view> <view> <u-popup v-model="show4" mode="center" border-radius="14"> <view class="popupMax"> <view class="title" style="color: red;"> 确认是否取消入库单据? </view> <view class="submit"> <view @click="show4=false" style="opacity: 0.8;">取消</view> <view style="color: #2979ff;" @click="quXiaoSubmit">确定</view> </view> </view> </u-popup> </view> </view> <view class="contentAll" v-if="pageStatue==2"> <phoneHead></phoneHead> <view class="customTab" style="margin-top: -10rpx;"> <view class="getBack" @click="conceal"> <image src="/static/image/zdyfh.png" mode=""></image> </view> <view class="title"> 选择产品 </view> <view class="right_submit" @click="rightClk"> {{submit_queDing}} </view> </view> <view class="productMax"> <view class="productMax-header"> <view class="brand-box"> <view class="picker"> <picker @change="brandChange" :value="brandNum" :range="brandListData"> <view class="noData" v-if="brandNum==-1" style="width: 81vw;"> 请选择品牌 </view> <view v-else style="width: 81vw;"> {{brandListData[brandNum]}} </view> </picker> </view> </view> <view class="brand-box"> <view class="picker"> <picker @change="suppliersChange" :value="suppliersNum" :range="suppliersListData"> <view class="noData" v-if="suppliersNum==-1" style="width: 81vw;"> 请选择供应商 </view> <view v-else style="width: 81vw;"> {{suppliersListData[suppliersNum]}} </view> </picker> </view> </view> <uni-search-bar bgColor="#fff" placeholder="请输入产品名称" v-model="rukuqueryKeywords"></uni-search-bar> </view> <scroll-view scroll-y="true" class="scroll-Y1 oneBox" @scrolltolower="upper"> <view class="uni-list" v-if="chukuproductList.length>0"> <checkbox-group class="gouxuan" v-for="(item1,index) in chukuproductList" :key="index" :title="item1.prductname" @click="selectProduct(item1)"> <view class="left"> <view class="dagou"> <checkbox :value="item1.item1" @click="selectProduct(item1)" :checked="item1.checked" /> </view> <view class="name"> <view class="title"> <view class="productName">{{item1.Name}}</view> </view> <view class="name-body"> <view class="block">品牌:{{item1.BrandName}}</view> <view class="L1">库存:{{item1.Quatitys}}</view> <view class="L1">单位:{{item1.StandardUnitName}}</view> </view> <view class="product-x"> <view class="block2">类别:{{item1.ProductTypeName}}</view> <view class="L2" v-if="$store.getters.isPermission('40f127d9-5ffc-4e4f-8449-aacb182ddae4')"> 成本:{{item1.CostPrice}}</view> <view class="L2">零售价:{{item1.RetailPrice}}</view> </view> </view> </view> </checkbox-group> <uni-load-more color="#3179F4" :status="status" /> </view> <view class="" v-else> <u-empty text="暂无数据" mode="list"></u-empty> </view> </scroll-view> </view> </view> <u-picker mode="selector" v-model="showWarehouse" :default-selector="[warehouseIndex]" :range="warehouseList" @confirm="warehouse"></u-picker> <u-picker mode="selector" v-model="showProductrRelevancy" :default-selector="[productrRelevancyIndex2]" :range="productrRelevancyList" @confirm="choiceProductrRelevancy"></u-picker> <u-picker mode="time" v-model="showTime" :defaultTime="defaultTime" :default-selector="[0]" :params="params" @confirm="businessTime"></u-picker> <u-picker mode="selector" v-model="showActionType" :default-selector="[actionTypeIndex]" :range="actionTypeList" @confirm="choiceActionType"></u-picker> </template> <script> import Headesnav from "@/components/headernav.vue" import phoneHead from "@/components/phoneHead/phoneHead.vue" import { EmployeeGetList, Brand_GetList, CrossWarehouses, HospitalId_Warehouse_WarehouseIn, HospitalId_Warehouse_Ruku_Save, HospitalId_Warehouse_Ruku_GetProduct, Hospital_Product_GognYingShang_List, HospitalId_Warehouse_Details, Hospital_Warehouse_Ruku_Update, HosptialId_Warehouse_Ruku_Audit, HosptialId_Warehouse_Order_CheXiao, Hospital_Warehouse_Order_QuXiao, GetProduct_GetList } from "@/api/api.js" import { ScanQRcode } from "@/api/home.js" import { WxJsSdk } from '@/api/wxapi.js' import { mapState } from 'vuex' export default { components: { Headesnav, phoneHead }, computed: { ...mapState(['currentSearchHospitalName', 'currentSearchHospitalId', 'loginUserInfo', 'companyId']) }, watch: { rukuqueryKeywords(newVal, oldVal) { this.rukuquery.keywords = newVal this.chukuproductList = [] this.rukuquery.pageIndex = 1 this.HospitalId_Warehouse_Ruku_GetProduct() } }, onLoad(e) { this.$nextTick(() => { this.$store.dispatch('loadPermissions'); }); let that = this const date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); month = month > 9 ? month : '0' + month; day = day > 9 ? day : '0' + day; this.defaultTime = `${year}-${month}-${day}` this.hospitalId = this.currentSearchHospitalId this.CrossWarehouses() this.EmployeeGetList() this.HospitalId_Warehouse_WarehouseIn() this.Hospital_Product_GognYingShang_List() this.Brand_GetList() this.HospitalId_Warehouse_Ruku_GetProduct() if (e.DetailsID != undefined) { // 详情 this.titleText = '入库详情' this.detailsStatus = 2 this.shenheStatus = e.shenheStatus this.DetailsID = e.DetailsID setTimeout(function() { // 详情接口 that.HospitalId_Warehouse_Details() }, 200) } else { // 添加 } }, data() { return { showTime: false, showProductrRelevancy: false, showActionType: false, showWarehouse: false, IsQuxiao: '', DetailsID: '', titleText: '添加入库', detailsStatus: 1, shenheStatus: '', queryXiugai: "", params: { year: true, month: true, day: true, hour: false, minute: false, second: false }, query: { "houseId": '', //仓库Id "userId": '', //经手人Id "businessDate": "", //业务日期 "baseId": '', //操作原因Id "allCostPrice": '', //总成本 "allPrice": '', //总金额 "allQuatity": '', //总数量 "memo": "", "products": [] }, rukuqueryKeywords: '', status: "more", rukuquery: { "houseId": '', //仓库Id "brandId": '', //品牌Id "supplierId": '', //供应商Id "keywords": "", //关键字 "pageSize": 15, "pageIndex": 1 }, hospitalId: '', warehouseIndex: '-1', warehouseList: [], warehouseList1: [], productrRelevancyList: [], productrRelevancyListData: [], productrRelevancyIndex: '-1', productrRelevancyIndex2: 0, defaultTime: '', actionTypeList: [], actionTypeList1: [], actionTypeIndex: 0, submit_queDing: '确定', pageStatue: 1, brandNum: '-1', brandListData: [], brandListData1: [], suppliersNum: '-1', suppliersListData: [], suppliersListData1: [], chukuproductList: [], scanList: [], scanList2: [], lastGouxuan: [], yijiGouxuan: [], productList1: [], productList2: [], show1: false, show2: false, show3: false, show4: false, deleteItem: '', submitSwitch: false, detailsData: '', detailsproductList1: '', ceshiArr: '', saomaArrList: [], } }, methods: { // 详情 HospitalId_Warehouse_Details() { let that = this uni.showLoading({ title: "加载中..." }) HospitalId_Warehouse_Details({ "id": that.DetailsID //列表返回Id }).then((res) => { that.detailsData = res.data for (var i = 0; i < that.detailsData.length; i++) { that.detailsData[i].ID = that.detailsData[i].KucunID } that.IsQuxiao = that.detailsData.IsQuxiao that.query.houseId = that.detailsData.HouseId for (var i = 0; i < that.warehouseList1.length; i++) { if (that.warehouseList1[i].Id == that.detailsData.HouseId) { that.warehouseIndex = i } } that.query.userId = that.detailsData.UserId for (var i = 0; i < that.productrRelevancyListData.length; i++) { if (that.productrRelevancyListData[i].EmployeeId == that.detailsData.UserId) { that.productrRelevancyIndex = i that.productrRelevancyIndex2 = i } } that.query.businessDate = that.detailsData.BusinessDate that.defaultTime = that.detailsData.BusinessDate that.query.baseId = that.detailsData.BaseId for (var i = 0; i < that.actionTypeList1.length; i++) { if (that.actionTypeList1[i].ID == that.detailsData.BaseId) { that.actionTypeIndex = i } } that.query.memo = that.detailsData.Memo for (var j = 0; j < that.detailsData.Products.length; j++) { that.detailsData.Products[j].Name = that.detailsData.Products[j].ProductName that.detailsData.Products[j].ProductTypeName = that.detailsData.Products[j].ProductType that.detailsData.Products[j].productSum = that.detailsData.Products[j].Quatity that.detailsData.Products[j].chnegbenSumPrice = that.detailsData.Products[j].AllCostPrice that.detailsData.Products[j].hejiSumPrice = that.detailsData.Products[j].AllPrice that.detailsData.Products[j].ID = that.detailsData.Products[j].ProductId } this.productList1 = that.detailsData.Products this.detailsproductList1 = that.detailsData.Products // 三个总数 let allSum = 0 for (var i = 0; i < that.detailsData.Products.length; i++) { allSum = Number(allSum) + Number(that.detailsData.Products[i].Quatity) allSum = Number(allSum).toFixed(2) } this.productList1.allQuatity = allSum this.productList1.allPrice = Number(that.detailsData.AllPrice).toFixed(2) this.productList1.allCostPrice = Number(that.detailsData.AllChengBen).toFixed(2) }).catch((err) => { }).finally(() => { uni.hideLoading() }) }, //保存 添加 baoCun() { let that = this this.query.businessDate = this.defaultTime this.query.allCostPrice = this.productList1.allCostPrice this.query.allPrice = this.productList1.allPrice this.query.allQuatity = this.productList1.allQuatity this.query.allQuatity = Number(this.query.allQuatity) this.query.products = [] for (var j = 0; j < this.productList1.length; j++) { let obj = {} obj.productId = that.productList1[j].ID obj.quantity = that.productList1[j].productSum obj.costPrice = that.productList1[j].CostPrice obj.allCostPrice = that.productList1[j].chnegbenSumPrice that.query.products.push(obj) } if (that.detailsStatus == 1) { // 添加 if (that.query.userId == '') { uni.showToast({ title: '请选择经手人', icon: 'none', duration: 1600 }) return } else if (that.query.baseId == '') { uni.showToast({ title: '请选择操作类型', icon: 'none', duration: 1600 }) return } else if (that.query.products == '') { uni.showToast({ title: '请选择入库的产品', icon: 'none', duration: 1600 }) return } for (var i = 0; i < that.productList1.length; i++) { if (that.productList1[i].productSum == 0 || that.productList1[i].productSum == '' || that .productList1[i] .productSum == undefined) { uni.showToast({ title: '产品数量不能为0', icon: 'none', duration: 2000 }) return } } if (that.submitSwitch) { return } uni.showLoading({ title: "加载中..." }) that.submitSwitch = true HospitalId_Warehouse_Ruku_Save(that.query).then((res) => { if (res.code == 200) { uni.showToast({ title: res.msg, duration: 2000 }); setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 2000) } else { uni.showToast({ title: res.msg, duration: 2000 }); } }).catch((err) => { }).finally(() => { uni.hideLoading() setTimeout(function() { that.submitSwitch = false }, 2000) }) } else if (that.detailsStatus == 2) { // 修改 that.queryXiugai = that.query that.queryXiugai.orderNo = that.detailsData.OrderNo uni.showLoading({ title: "加载中..." }) if (that.queryXiugai.products == '') { uni.showToast({ title: '请选择入库的产品', icon: 'none', duration: 1600 }) return } for (var i = 0; i < that.productList1.length; i++) { if (that.productList1[i].productSum == 0 || that.productList1[i].productSum == '' || that .productList1[i] .productSum == undefined) { uni.showToast({ title: '产品数量不能为0', icon: 'none', duration: 2000 }) return } } Hospital_Warehouse_Ruku_Update(that.queryXiugai).then((res) => { if (res.code == 200) { uni.showToast({ title: res.msg, duration: 2000 }); setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 2000) } else { uni.showToast({ title: res.msg, duration: 2000 }); } }).catch((err) => { }).finally(() => { uni.hideLoading() }) } }, // 审核 shenHeSubmit() { let that = this uni.showLoading({ title: "加载中..." }) HosptialId_Warehouse_Ruku_Audit({ "orderNo": that.detailsData.OrderNo //订单号 }).then((res) => { if (res.code == 200) { uni.showToast({ title: res.msg, duration: 2000 }); that.show2 = false setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 2000) } else { uni.showToast({ title: res.msg, duration: 2000 }); } }).catch((err) => { }).finally(() => { uni.hideLoading() }) }, // 撤销 cheXiaoSubmit() { let that = this uni.showLoading({ title: "加载中..." }) HosptialId_Warehouse_Order_CheXiao({ "id": that.DetailsID //列表返回Id }).then((res) => { if (res.code == 200) { uni.showToast({ title: res.msg, duration: 2000 }); that.show3 = false setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 2000) } else { uni.showToast({ title: res.msg, duration: 2000 }); } }).catch((err) => { }).finally(() => { uni.hideLoading() }) }, // 取消已审核的数据 quXiaoSubmit() { let that = this uni.showLoading({ title: "加载中..." }) Hospital_Warehouse_Order_QuXiao({ "id": that.DetailsID, //列表返回Id "type": 2 //单据类型 1出库 2入库 }).then((res) => { if (res.code == 200) { uni.showToast({ title: res.msg, duration: 2000 }); that.show4 = false setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 2000) } else { uni.showToast({ title: res.msg, duration: 2000 }); } }).catch((err) => { }).finally(() => { uni.hideLoading() }) }, // 返回上一页 quxiao() { setTimeout(function() { uni.navigateBack({ delta: 1, //返回层数,2则上上页 }) }, 20) }, // 获取入库产品列表数据 HospitalId_Warehouse_Ruku_GetProduct() { let that = this that.rukuquery.houseId = that.query.houseId HospitalId_Warehouse_Ruku_GetProduct(that.rukuquery).then((res) => { this.chukuproductList = res.data for (var i = 0; i < this.chukuproductList.length; i++) { this.chukuproductList[i].checked = false } for (var j = 0; j < that.chukuproductList.length; j++) { for (var k = 0; k < that.lastGouxuan.length; k++) { if (that.chukuproductList[j].ID == that.lastGouxuan[k].ID) { that.chukuproductList[j].checked = true } } } if (res.data.length >= that.rukuquery.pageSize) { that.status = "more" } else { that.status = "no-more" } }).catch((err) => { }) }, upper() { let that = this; if (that.status == "no-more") { return } that.status = "loading"; that.rukuquery.pageIndex++; HospitalId_Warehouse_Ruku_GetProduct(that.rukuquery).then(res => { let addArr = res.data for (var i = 0; i < addArr.length; i++) { addArr[i].checked = false; } that.chukuproductList = that.chukuproductList.concat(addArr) if (res.data.length >= that.rukuquery.pageSize) { that.status = "more" } else { that.status = "no-more" } }).catch(err => { }) }, // 门店仓库列表 CrossWarehouses() { let that = this CrossWarehouses({ // "hospitalId": this.hospitalId, "hospitalId": that.loginUserInfo.WarehouseId, 'keywords': '', }).then((res) => { this.warehouseList1 = res.data res.data.forEach(item => { this.warehouseList.push(item.Name) }) for (var i = 0; i < this.warehouseList1.length; i++) { if (that.warehouseList1[i].Id == that.loginUserInfo.WarehouseId) { that.warehouseIndex = i this.query.houseId = this.warehouseList1[i].Id } } }).catch((err) => { }) }, //入库仓库选择 warehouse(e) { this.warehouseIndex = e[0] this.query.houseId = this.warehouseList1[this.warehouseIndex].Id this.hospitalId = this.warehouseList1[this.warehouseIndex].Id }, //员工列表数据 EmployeeGetList() { let that = this EmployeeGetList({ "hospitalId": this.hospitalId, //门店id "keywords": '' //关键字查询 }).then((res) => { this.productrRelevancyListData = res.data res.data.forEach(item => { this.productrRelevancyList.push(item.EmployeeName) }) }).catch(err => {}) }, //经手人 choiceProductrRelevancy(e) { this.productrRelevancyIndex = e[0] this.productrRelevancyIndex2 = Number(this.productrRelevancyIndex) this.query.userId = this.productrRelevancyListData[this.productrRelevancyIndex].EmployeeId }, //业务日期 businessTime(e) { this.defaultTime = `${e.year}-${e.month}-${e.day}` }, // 操作类型列表 HospitalId_Warehouse_WarehouseIn() { HospitalId_Warehouse_WarehouseIn({ "type": 1 //操作类型 1入库 2院用出库 3非院用出库 }).then((res) => { this.actionTypeList1 = res.data res.data.forEach(item => { this.actionTypeList.push(item.Name) }) this.query.baseId = this.actionTypeList1[0].ID }).catch((err) => { }) }, // 操作类型选择 choiceActionType(e) { this.actionTypeIndex = e[0] this.query.baseId = this.actionTypeList1[this.actionTypeIndex].ID }, scanProduct() { let that = this WxJsSdk(that.companyId, 'scanQRCode').then(wx => { wx.scanQRCode({ needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有 success: function(res) { var result = res.resultStr.slice(7); // 当needResult 为 1 时,扫码返回的结果 uni.showLoading({ title: "加载中..." }) HospitalId_Warehouse_Ruku_GetProduct({ "houseId": that.hospitalId, //仓库Id "brandId": '', //品牌Id "supplierId": '', //供应商Id "keywords": result, //关键字 "pageSize": 10, "pageIndex": 1 }).then((res) => { if (res.data.length > 0) { that.ceshiArr = res.data[0] // 合并详情已有的产品选择的产品 // 排除已经有的产品数据 不必要再次加入 for (var m = 0; m < that.detailsproductList1.length; m++) { if (that.detailsproductList1[m].ID == that.ceshiArr .ID || that.detailsproductList1[m].KucunID == that .ceshiArr.ID) { return } } for (var i = 0; i < that.saomaArrList.length; i++) { if (that.saomaArrList[i].ID == that.ceshiArr.ID) { return } } that.saomaArrList.push(that.ceshiArr) that.productList1.push(res.data[0]) that.productList1.allQuatity = 0 that.productList1.allCostPrice = 0 that.productList1.allPrice = 0 for (var i = 0; i < that.productList1.length; i++) { // 添加一个产品数量 成本总金额 合计金额 if ('productSum' in that.productList1[i]) { // 原来就勾选了的数据不用添加字段 } else { //新勾选的数据添加一些需要的字段 that.productList1[i].productSum = 0 that.productList1[i].chnegbenSumPrice = 0 that.productList1[i].hejiSumPrice = 0 } } for (var j = 0; j < that.productList1.length; j++) { that.productList1.allQuatity = Number(that.productList1 .allQuatity) + Number(that.productList1[j] .productSum) that.productList1.allQuatity = Number(that.productList1 .allQuatity).toFixed(2) that.productList1.allCostPrice = Number(that .productList1.allCostPrice) + Number(that .productList1[j] .CostPrice) * Number(that.productList1[j] .productSum) that.productList1.allCostPrice = Number(that .productList1.allCostPrice).toFixed(2) that.productList1.allPrice = Number(that.productList1 .allPrice) + Number(that.productList1[j] .RetailPrice) * Number(that.productList1[j].productSum) that.productList1.allPrice = Number(that.productList1 .allPrice).toFixed(2) } this.productList1 = this.deduplicateById(this.productList1) } else { uni.showToast({ title: '未查询到产品', icon: 'none', duration: 2000 }); return } }).catch((err) => { }).finally(() => { uni.hideLoading() }) } }); }); }, deduplicateById(arr) { const map = new Map(); arr.forEach(item => { map.set(item.ID, item); }); return Array.from(map.values()); }, //app扫码 // #ifndef H5 scanProduct() { let that = this uni.scanCode({ success: function(res) { var result = res.result; // 当needResult 为 1 时,扫码返回的结果 uni.showLoading({ title: "加载中..." }) HospitalId_Warehouse_Ruku_GetProduct({ "houseId": that.hospitalId, //仓库Id "brandId": '', //品牌Id "supplierId": '', //供应商Id "keywords": result, //关键字 "pageSize": 10, "pageIndex": 1 }).then((res) => { if (res.data.length > 0) { that.ceshiArr = res.data[0] // 合并详情已有的产品选择的产品 // 排除已经有的产品数据 不必要再次加入 for (var m = 0; m < that.detailsproductList1.length; m++) { if (that.detailsproductList1[m].ID == that.ceshiArr.ID || that .detailsproductList1[m].KucunID == that.ceshiArr.ID) { return } } for (var i = 0; i < that.saomaArrList.length; i++) { if (that.saomaArrList[i].ID == that.ceshiArr.ID) { return } } that.saomaArrList.push(that.ceshiArr) that.productList1.push(res.data[0]) that.productList1.allQuatity = 0 that.productList1.allCostPrice = 0 that.productList1.allPrice = 0 for (var i = 0; i < that.productList1.length; i++) { // 添加一个产品数量 成本总金额 合计金额 if ('productSum' in that.productList1[i]) { // 原来就勾选了的数据不用添加字段 } else { //新勾选的数据添加一些需要的字段 that.productList1[i].productSum = 0 that.productList1[i].chnegbenSumPrice = 0 that.productList1[i].hejiSumPrice = 0 } } for (var j = 0; j < that.productList1.length; j++) { that.productList1.allQuatity = Number(that.productList1 .allQuatity) + Number(that.productList1[j] .productSum) that.productList1.allQuatity = Number(that.productList1 .allQuatity).toFixed(2) that.productList1.allCostPrice = Number(that .productList1.allCostPrice) + Number(that .productList1[j] .CostPrice) * Number(that.productList1[j] .productSum) that.productList1.allCostPrice = Number(that .productList1.allCostPrice).toFixed(2) that.productList1.allPrice = Number(that.productList1 .allPrice) + Number(that.productList1[j] .RetailPrice) * Number(that.productList1[j].productSum) that.productList1.allPrice = Number(that.productList1 .allPrice).toFixed(2) } } else { uni.showToast({ title: '未查询到产品', icon: 'none', duration: 2000 }); return } }).catch((err) => { }).finally(() => { uni.hideLoading() }) } }); }, // #endif //去选择产品 showProduct() { this.pageStatue = 2 this.chukuproductList = [] this.rukuquery.pageIndex = 1 this.HospitalId_Warehouse_Ruku_GetProduct() }, //品牌 Brand_GetList() { let that = this Brand_GetList().then(res => { this.brandListData1 = res.data res.data.forEach(item => { this.brandListData.push(item.Name) }) this.brandListData1.unshift('全部') this.brandListData.unshift('全部') }).catch(err => {}) }, //品牌选择 brandChange(e) { this.brandNum = e.detail.value if (this.brandNum == 0) { this.rukuquery.brandId = '' } else { this.rukuquery.brandId = this.brandListData1[this.brandNum].ID } this.chukuproductList = [] this.rukuquery.pageIndex = 1 this.HospitalId_Warehouse_Ruku_GetProduct() }, //供应商列表 Hospital_Product_GognYingShang_List() { Hospital_Product_GognYingShang_List({ "hospitalId": this.hospitalId, "keywords": " ", }).then((res) => { this.suppliersListData1 = res.data res.data.forEach(item => { this.suppliersListData.push(item.Name) }) this.suppliersListData.unshift('全部') this.suppliersListData1.unshift('全部') }).catch((err) => { }) }, //供应商 suppliersChange(e) { this.suppliersNum = e.detail.value if (this.suppliersNum == 0) { this.rukuquery.supplierId = '' } else { this.rukuquery.supplierId = this.suppliersListData1[this.suppliersNum].ID } this.chukuproductList = [] this.rukuquery.pageIndex = 1 this.HospitalId_Warehouse_Ruku_GetProduct() }, //自定义返回 conceal() { this.pageStatue = 1 }, //选择产品 selectProduct(e) { if (this.lastGouxuan.length > 0) { for (var m = 0; m < this.lastGouxuan.length; m++) { if (this.lastGouxuan[m].ID == e.ID) { e.checked = false this.lastGouxuan[m].checked = false this.lastGouxuan.splice(m, 1) break } else { e.checked = true } } } else { e.checked = (!e.checked) } this.lastGouxuan = [] let xuanzhongNum = 0 for (var i = 0; i < this.chukuproductList.length; i++) { if (this.chukuproductList[i].checked == true) { xuanzhongNum += 1 } } for (var i = 0; i < this.chukuproductList.length; i++) { if (this.chukuproductList[i].checked == true) { this.yijiGouxuan.push(this.chukuproductList[i]) } for (var p = 0; p < this.yijiGouxuan.length; p++) { if (this.yijiGouxuan[p].checked == false) { this.yijiGouxuan.splice(p, 1) } } } const map = new Map(); const newArr = this.yijiGouxuan.filter(v => !map.has(v.ID) && map.set(v.ID, v)); this.yijiGouxuan = newArr for (var i = 0; i < this.yijiGouxuan.length; i++) { if (this.yijiGouxuan[i].checked == true) { this.lastGouxuan.push(this.yijiGouxuan[i]) } } this.lastGouxuan = [...new Set(this.lastGouxuan)] if (this.lastGouxuan.length > 0) { this.submit_queDing = '确定' + '(' + this.lastGouxuan.length + ')' } else { this.submit_queDing = '确定' } }, //确定产品 rightClk(e) { let that = this // 合并详情已有的产品选择的产品 // 排除已经有的产品数据 不必要再次加入 for (var m = 0; m < that.detailsproductList1.length; m++) { for (var n = 0; n < that.lastGouxuan.length; n++) { if (that.detailsproductList1[m].ID == that.lastGouxuan[n].ID) { that.lastGouxuan.splice(n, 1) } } } if (that.detailsStatus == 2) { this.productList1 = this.lastGouxuan.concat(this.detailsproductList1) } else { if (that.saomaArrList.length == 0) { this.productList1 = this.lastGouxuan } else { this.productList1 = this.lastGouxuan.concat(this.saomaArrList) } } this.productList1.allQuatity = 0 this.productList1.allCostPrice = 0 this.productList1.allPrice = 0 for (var i = 0; i < this.productList1.length; i++) { // 添加一个产品数量 成本总金额 合计金额 if ('productSum' in this.productList1[i]) { // 原来就勾选了的数据不用添加字段 } else { //新勾选的数据添加一些需要的字段 this.productList1[i].productSum = 0 this.productList1[i].chnegbenSumPrice = 0 this.productList1[i].hejiSumPrice = 0 } } for (var j = 0; j < this.productList1.length; j++) { this.productList1.allQuatity = Number(this.productList1.allQuatity) + Number(this.productList1[j] .productSum) this.productList1.allQuatity = Number(this.productList1.allQuatity).toFixed(2) this.productList1.allCostPrice = Number(this.productList1.allCostPrice) + Number(this.productList1[j] .CostPrice) * Number(this.productList1[j].productSum) this.productList1.allCostPrice = Number(this.productList1.allCostPrice).toFixed(2) this.productList1.allPrice = Number(this.productList1.allPrice) + Number(this.productList1[j] .RetailPrice) * Number(this.productList1[j].productSum) this.productList1.allPrice = Number(this.productList1.allPrice).toFixed(2) } this.pageStatue = 1 if (this.lastGouxuan.length > 0) { this.submit_queDing = '确定' + '(' + this.lastGouxuan.length + ')' } else { this.submit_queDing = '确定' } }, // 输入数量时金额全部重新计算 shuruSum(event, item) { let that = this let value = event.detail.value; if (value < 1) { value = 0; } else { const numValue = parseInt(value, 10); if (!Number.isNaN(numValue)) { value = numValue; } else { value = 1; } } event.detail.value = value this.$nextTick(() => { item.productSum = value }) // 计算之前全部赋值为0 在重新做计算 this.productList1.allQuatity = 0 this.productList1.allCostPrice = 0 this.productList1.allPrice = 0 setTimeout(function() { // 计算每个产品 单个总价 for (var j = 0; j < that.productList1.length; j++) { that.productList1[j].chnegbenSumPrice = Number(that.productList1[j].productSum) * Number( that .productList1[j].CostPrice) that.productList1[j].chnegbenSumPrice = that.productList1[j].chnegbenSumPrice.toFixed(2) that.productList1[j].hejiSumPrice = Number(that.productList1[j].productSum) * Number(that .productList1[ j].RetailPrice) that.productList1[j].hejiSumPrice = that.productList1[j].hejiSumPrice.toFixed(2) } // 计算全部总价格 for (var m = 0; m < that.productList1.length; m++) { that.productList1.allQuatity = Number(that.productList1.allQuatity) + Number(that .productList1[m] .productSum) that.productList1.allQuatity = Number(that.productList1.allQuatity).toFixed(2) that.productList1.allCostPrice = Number(that.productList1.allCostPrice) + Number(that .productList1[m] .CostPrice) * Number(that.productList1[m].productSum) that.productList1.allCostPrice = Number(that.productList1.allCostPrice).toFixed(2) that.productList1.allPrice = Number(that.productList1.allPrice) + Number(that.productList1[ m] .RetailPrice) * Number(that.productList1[m].productSum) that.productList1.allPrice = Number(that.productList1.allPrice).toFixed(2) } }, 20) }, // 输入成本价格时 重新计算金额 shuruChengBenJia(event, item) { let that = this let value = Number(event.detail.value) if (value < 0) { this.$nextTick(() => { item.CostPrice = 0 event.detail.value = 0 }) return } let decimalPart = Math.floor(value * 100) if (decimalPart != value * 100) { // 不相等就是不止二位小数 value = Number(value).toFixed(2) } // 更新数据绑定的值 event.detail.value = value this.$nextTick(() => { item.CostPrice = value }) // 计算之前全部赋值为0 在重新做计算 this.productList1.allQuatity = 0 this.productList1.allCostPrice = 0 this.productList1.allPrice = 0 // 计算每个产品 单个总价 for (var j = 0; j < this.productList1.length; j++) { that.productList1[j].chnegbenSumPrice = Number(that.productList1[j].productSum) * Number(that .productList1[j].CostPrice) that.productList1[j].chnegbenSumPrice = that.productList1[j].chnegbenSumPrice.toFixed(2) that.productList1[j].hejiSumPrice = Number(that.productList1[j].productSum) * Number(that.productList1[ j].RetailPrice) that.productList1[j].hejiSumPrice = that.productList1[j].hejiSumPrice.toFixed(2) } // 计算全部总价格 for (var m = 0; m < this.productList1.length; m++) { that.productList1.allQuatity = Number(that.productList1.allQuatity) + Number(that.productList1[m] .productSum) that.productList1.allQuatity = Number(that.productList1.allQuatity).toFixed(2) that.productList1.allCostPrice = Number(that.productList1.allCostPrice) + Number(that.productList1[m] .CostPrice) * Number(that.productList1[m].productSum) that.productList1.allCostPrice = Number(that.productList1.allCostPrice).toFixed(2) that.productList1.allPrice = Number(that.productList1.allPrice) + Number(that.productList1[m] .RetailPrice) * Number(that.productList1[m].productSum) that.productList1.allPrice = Number(that.productList1.allPrice).toFixed(2) } }, //删除产品 deleteList(e) { this.show1 = true this.deleteItem = e }, //确定删除产品 confirmRemove() { let that = this for (var j = 0; j < this.productList1.length; j++) { if (that.productList1[j].ID == that.deleteItem.ID) { that.productList1[j].productSum = 0 that.productList1[j].chnegbenSumPrice = 0 that.productList1[j].hejiSumPrice = 0 that.productList1.splice(j, 1) break } } for (var j = 0; j < this.detailsproductList1.length; j++) { if (that.detailsproductList1[j].ID == that.deleteItem.ID) { that.detailsproductList1[j].productSum = 0 that.detailsproductList1[j].chnegbenSumPrice = 0 that.detailsproductList1[j].hejiSumPrice = 0 that.detailsproductList1.splice(j, 1) break } } for (var j = 0; j < this.saomaArrList.length; j++) { if (that.saomaArrList[j].ID == that.deleteItem.ID) { that.saomaArrList[j].productSum = 0 that.saomaArrList[j].chnegbenSumPrice = 0 that.saomaArrList[j].hejiSumPrice = 0 that.saomaArrList.splice(j, 1) break } } for (var j = 0; j < this.lastGouxuan.length; j++) { if (that.lastGouxuan[j].ID == that.deleteItem.ID) { that.lastGouxuan[j].productSum = 0 that.lastGouxuan[j].chnegbenSumPrice = 0 that.lastGouxuan[j].hejiSumPrice = 0 that.lastGouxuan.splice(j, 1) break } } if (this.lastGouxuan.length > 0) { this.submit_queDing = '确定' + '(' + this.lastGouxuan.length + ')' } else { this.submit_queDing = '确定' } this.show1 = false // 计算之前全部赋值为0 在重新做计算 this.productList1.allQuatity = 0 this.productList1.allCostPrice = 0 this.productList1.allPrice = 0 // 计算全部总价格 for (var m = 0; m < this.productList1.length; m++) { that.productList1.allQuatity = Number(that.productList1.allQuatity) + Number(that.productList1[m] .productSum) that.productList1.allQuatity = Number(that.productList1.allQuatity).toFixed(2) that.productList1.allCostPrice = Number(that.productList1.allCostPrice) + Number(that.productList1[m] .CostPrice) * Number(that.productList1[m].productSum) that.productList1.allCostPrice = Number(that.productList1.allCostPrice).toFixed(2) that.productList1.allPrice = Number(that.productList1.allPrice) + Number(that.productList1[m] .RetailPrice) * Number(that.productList1[m].productSum) that.productList1.allPrice = Number(that.productList1.allPrice).toFixed(2) } }, } } </script> <style lang="scss" scoped> @import '@/publicStyle/itemManagementStyle/WarehouseList/scss/AddWarehouseEntry.scss' </style> 报Extraneous non-props attributes (DetailsID, shenheStatus) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. at <AddWarehouseEntry>错误
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄毛火烧雪下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值