| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <template>
- <view class="mainBox">
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择产品" @clickLeft="backAdd">
- <!--右菜单-->
- <template slot="right">
- <u-button type="success" size="small" class="u-reset-button" @click="classification"
- text="选择分类"></u-button>
- </template>
- </uni-nav-bar>
- <view class="top-wrapper">
- <uni-section class="dimension" v-if="obtain == '仓库'">
- <uni-data-select @change="(e)=>onchange(e)" v-model="dimension" :clear="false"
- :localdata="dimensionList"></uni-data-select>
- </uni-section>
- <uni-section v-else>
- <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="searchKey" placeholder="关键字">
- </uni-easyinput>
- </uni-section>
- <button class="search_btn" @click="getData({})">搜索</button>
- <image class="menu_icon" @click="handleSearch" src="~@/static/pda/menu.svg"></image>
- </view>
- <view class="wrapper">
- <u-list @scrolltolower="scrolltolower" class="listContent">
- <checkbox-group v-for="(item, index) in tableList" :key="index"
- @change="e => selectVal(e, item, index)">
- <label>
- <view class="listBox">
- <view class="listBox-sel">
- <checkbox :value="item.id" color="#fff" :disabled="item.disabled"
- :checked="item.checked" />
- </view>
- <view class="listBox-con">
- <view class="listBox-bottom">
- <view>
- <text>{{!fieldShow?'编码':'物品编码'}}:</text>
- <text class="value">{{ item.code }}</text>
- </view>
- <view>
- <text>{{!fieldShow?'名称':'物品名称'}}:</text>
- <text class="value">{{ item.name }}</text>
- </view>
- <view class="label-s">
- <text>牌号:</text>
- <text class="value">{{ item.brandNum }}</text>
- </view>
- <view class="label-s">
- <text>型号:</text>
- <text class="value">{{ item.categoryModel }}</text>
- </view>
- <view>
- <text>规格:</text>
- <text class="value">{{ item.specification }}</text>
- </view>
- <view class="label-s" v-if="dimension == 3">
- <text>批次号:</text>
- <text class="value">{{ item.batchNo }}</text>
- </view>
- <view class="label-s">
- <text>级别:</text>
- <text class="value">{{ item.level }}</text>
- </view>
- <view class="label-s" v-if="fieldShow">
- <text>计量数量:</text>
- <text class="value">{{ item.measureQuantity }}</text>
- </view>
- <view class="label-s" v-if="fieldShow">
- <text>计量单位:</text>
- <text class="value">{{ item.measureUnit }}</text>
- </view>
- <view class="label-s">
- <text>重量:</text>
- <text class="value">{{ item.weight }}</text>
- </view>
- <view class="label-s">
- <text>重量单位:</text>
- <text class="value">{{ item.weightUnit }}</text>
- </view>
- <view class="label-s">
- <text>分类:</text>
- <text class="value">{{ item.categoryLevelPath }}</text>
- </view>
- <view v-if="dimension == 3">
- <text>包装编码:</text>
- <text class="value">{{ item.packageNo }}</text>
- </view>
- <view class="label-s" v-if="dimension == 3">
- <text>包装数量:</text>
- <text class="value">{{ item.packingQuantity }}</text>
- </view>
- <view class="label-s" v-if="dimension == 3">
- <text>包装单位:</text>
- <text class="value">{{ item.packingUnit }}</text>
- </view>
- <view v-if="dimension == 3 || dimension == 4">
- <text>发货条码:</text>
- <text class="value">{{ item.barcodes }}</text>
- </view>
- <view v-if="dimension == 4">
- <text>物料编码:</text>
- <text class="value">{{ item.no }}</text>
- </view>
- <view v-if="dimension == 3 || dimension == 4">
- <text>物料代号:</text>
- <text class="value">{{ item.materielDesignation }}</text>
- </view>
- <view v-if="dimension == 3 || dimension == 4">
- <text>客户代号:</text>
- <text class="value">{{ item.clientCode }}</text>
- </view>
- <view v-if="dimension == 3 || dimension == 4">
- <text>刻码:</text>
- <text class="value">{{ item.engrave }}</text>
- </view>
- <view v-if="dimension == 3 || dimension == 4">
- <text>仓库:</text>
- <text class="value">{{ item.warehouseName }}</text>
- </view>
- </view>
- </view>
- </view>
- </label>
- </checkbox-group>
- <u-empty class="noDate" style="margin-top: 20vh" v-if="!tableList.length"></u-empty>
- </u-list>
- </view>
- <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
- :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
- childrenKey="children" />
- <view class="footer">
- <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
- <view class="selBtn">选择( {{ checkListLen }} )</view>
- </u-button>
- </view>
- <screenAccess :dataSources="obtain =='主数据'?'1':'0'" ref="screen" @succeed="getData" />
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import screenAccess from './screenAccess.vue'
- import {
- getInventoryTotalAPI
- } from '@/api/wms/index.js'
- import {
- treeByPid
- } from '@/api/pda/workOrder.js'
- import {
- getProductList,
- getBatchDetails,
- getInventoryDetails,
- getMaterielDetails,
- } from '@/api/repair'
- import {
- getList
- } from '@/api/classifyManage/itemInformation.js'
- export default {
- components: {
- screenAccess
- },
- data() {
- return {
- tableList: [],
- obtain: '主数据',
- dimension: '1', // 列表维度
- categoryLevelId: 6, // 分类id(默认6 查询备品备件)
- selectedData: ['6'],
- classificationList: [],
- pageNum: 1,
- isEnd: false,
- detailsData: {},
- checkedkList: [],
- searchKey: '',
- selectType: '1', // 1 单选 2 多选
- dimensionList: [{
- value: '4',
- text: '物料维度'
- },
- {
- value: '3',
- text: '包装维度'
- },
- {
- value: '2',
- text: '批次维度'
- },
- {
- value: '1',
- text: '物品维度'
- },
- ]
- }
- },
- computed: {
- checkListLen() {
- return this.checkedkList.length;
- },
- // 物品字段
- fieldShow() {
- return this.obtain == '仓库';
- },
- },
- onLoad(params) {
- this.obtain = params.obtain || '主数据';
- this.selectType = params.selectType || '1';
- },
- onShow() {
- this.getTreeList();
- // this.getData();
- },
- methods: {
- // 获取页面数据
- getData(parameter = {}) {
- let data = parameter;
- if (!data.scroll) {
- this.isEnd = false;
- this.pageNum = 1;
- this.tableList = [];
- } else {
- delete data.scroll;
- }
- if (this.obtain == '仓库') {
- this.changeDimension(this.dimension, parameter);
- } else {
- let obj = this.$refs.screen.mainForm || {};
- // 查询主数据
- this.warehouseData(obj);
- }
- },
- onchange(e) {
- this.dimension = e;
- this.getData({});
- },
- handleSearch() {
- this.$refs.screen.open();
- },
- //返回添加页
- backAdd() {
- uni.navigateBack();
- },
- // 主数据
- warehouseData(data = {}) {
- let form = {
- ...data,
- searchKey: this.searchKey,
- pageNum: this.pageNum,
- size: 15,
- categoryLevelId: this.categoryLevelId
- }
- uni.showLoading({
- title: '加载中'
- })
- getList(form).then((res) => {
- let list = res.list.map((el) => {
- el.categoryModel = el.modelType;
- el.categoryName = el.name;
- el.categoryCode = el.code;
- return el;
- });
- if (this.pageNum == 1) {
- this.tableList = list;
- } else {
- this.tableList.push(...list);
- }
- this.pageNum += 1
- this.isEnd = this.tableList.length >= res.count;
- uni.hideLoading();
- }).then((e) => {
- uni.hideLoading();
- })
- },
- // 仓库数据
- changeDimension(dimension, parameter = {}) {
- if (this.isEnd) {
- return
- }
- uni.showLoading({
- title: '加载中'
- })
- return new Promise(async (resolve, reject) => {
- try {
- let params = {
- // assetName: this.assetName,
- // dimension: this.dimension,
- ...parameter,
- pageNum: this.pageNum,
- size: 15,
- categoryLevelId: this.categoryLevelId
- }
- const api = dimension == 1 ? getProductList : dimension == 2 ?
- getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
- let res = await api(params);
- let list = res.list.map((el) => {
- el.modelType = el.categoryModel;
- el.name = el.categoryName;
- el.code = el.categoryCode;
- return el;
- });
- if (this.pageNum == 1) {
- this.tableList = list;
- } else {
- this.tableList.push(...list);
- }
- this.pageNum += 1;
- this.isEnd = this.tableList.length >= res.count;
- uni.hideLoading();
- resolve();
- } catch (error) {
- uni.hideLoading()
- reject()
- }
- })
- },
- classification() {
- this.$refs.treePicker._show();
- },
- scrolltolower() {
- if (this.isEnd) {
- return
- }
- this.getData({
- scroll: true
- });
- },
- // 选择
- selectVal(e, val, index) {
- this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
- this.tableList.forEach((item, i) => {
- if (item.id != val.id) {
- this.$set(this.tableList[i], 'checked', false)
- }
- })
- this.checkedkList = this.tableList.filter(item => item.checked)
- },
- getTreeList() {
- treeByPid({
- ids: [6]
- }).then(res => {
- this.classificationList = res;
- this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
- })
- },
- confirm(id, name, rootCategoryLevelId) {
- // this.rootCategoryLevelId = rootCategoryLevelId
- this.categoryLevelId = id;
- this.tableList = [];
- this.getData();
- },
- async jumpAdd() {
- let list = this.checkedkList;
- if (list.length == 0) {
- this.$refs.uToast.show({
- type: "warning",
- message: "请至少选择一条产品数据",
- })
- return;
- }
- //获取仓库库存
- // if (this.obtain == '仓库') {
- // let codeList = list.map((item) => item.code);
- // let inventoryTotalList = await getInventoryTotalAPI(codeList);
- // list.forEach((item) => {
- // let find =
- // inventoryTotalList.find((key) => key.code == item.code) || {};
- // item.availableCountBase = find.availableCountBase;
- // });
- // }
- // 单选
- if (this.selectType == '1') {
- uni.$emit('updateScheme', list[0]);
- }
- this.back();
- }
- }
- }
- </script>
- <style scoped lang="scss">
- @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
- .mainBox {
- height: 100vh;
- display: flex;
- flex-direction: column;
- .wrapper {
- // flex: 1;
- height: calc(100vh - 250rpx);
- overflow: hidden;
- }
- //底部按钮
- .footer {
- height: 45px;
- position: relative;
- display: flex;
- justify-content: space-between;
- align-items: center;
- bottom: 0;
- width: 100%;
- height: 50px;
- border-top: 1px solid #eeecec;
- background-color: #ffffff;
- z-index: 999;
- .bottom {
- margin-left: 10rpx;
- }
- .u-reset-button {
- position: absolute;
- right: 10rpx;
- top: 20rpx;
- width: 150rpx;
- }
- }
- .top-wrapper {
- background-color: #fff;
- display: flex;
- width: 750rpx;
- height: 88rpx;
- padding: 16rpx 32rpx;
- align-items: center;
- gap: 16rpx;
- /deep/.uni-section {
- margin-top: 0px;
- }
- /deep/.uni-section-header {
- padding: 0px;
- }
- .search_btn {
- width: 120rpx;
- height: 70rpx;
- line-height: 70rpx;
- padding: 0 24rpx;
- background: $theme-color;
- font-size: 32rpx;
- color: #fff;
- margin: 0;
- margin-left: 26rpx;
- }
- .menu_icon {
- width: 44rpx;
- height: 44rpx;
- margin-left: 14rpx;
- }
- }
- .dimension {
- width: calc(100% - 270rpx);
- }
- }
- </style>
|