123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <div class="my-container">
- <div class="bill-main">
- <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList" @resert="onRefresh"
- @detail="shortBarge" @onRefresh="onRefresh">
- </module-view>
- </div>
- <batchbyOneModal ref="batchbyOneModal" />
- </div>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/currency";
- import batchbyOneModal from './components/batchbyOneModal.vue'
- @Component({components:{batchbyOneModal}})
- export default class Store extends Vue {
- timeNum = 0;
- calculateCount = 0;
- skuInfo : any = ''
- storeHouseInfo : any = ''
- tableInfo : any = ''
- timer : any = null
- config : any = {
- attr: {
- calculateH: true
- },
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- // {
- // span: 6,
- // label: '标题',
- // prop: 'skuTitle',
- // component: 'by-input',
- // // labelWidth: '70px',
- // compConfig: {
- // attr: {
- // placeholder: '请输入标题',
- // clearable: true
- // }
- // }
- // },
- {
- span: 6,
- label: '物料编码',
- prop: 'skuCode',
- component: 'by-input',
- // labelWidth: '70px',
- compConfig: {
- attr: {
- placeholder: '请输入物料编码',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '69码-商品条码',
- prop: 'barCode',
- labelWidth: '130px',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '69码-商品条码',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '财务编号',
- prop: 'accountingCode',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入财务编号',
- clearable: true
- }
- }
- }
- ]
- ]
- },
- tool: {
- tools: {
- refresh: true,
- search: true,
- },
- customTools:[{
- name:'短驳调拨',
- icon:'el-icon-discount',
- event:{
- click: () => {
- this.shortBargeHandel()
- }
- }
- }]
- },
- table: {
- attr: {
- size: 'mini',
- align: 'left',
- height: '620',
- checkbox: true,
- },
- columns: [
- {
- // width: '200px',
- title: '标题',
- field: 'skuTitle',
- // isDetail: true,
- fixed: 'left'
- },
- {
- // width: '200px',
- title: '副标题',
- field: 'skuSubtitle',
- },
- {
- // width: '140px',
- title: '物料编码',
- field: 'skuCode',
- },
- {
- // width: '140px',
- title: '69码-商品条码',
- field: 'barCode',
- },
- {
- // width: '140px',
- title: '财务编号',
- field: 'accountingCode',
- }
- ]
- },
- }
- mounted() {
- this.timer = setInterval(() => {
- this.getDataList()
- this.initTable();
- }, 300)
- }
- // 计算高度
- initTable() {
- if (!this.$refs.moduleView) {
- this.calculateCount++;
- if (this.calculateCount > 5) return;
- setTimeout(() => {
- this.initTable()
- }, 500)
- return
- }
- let tableId : any = (this as any).$refs.moduleView.tableID;
- this.config.table.attr.height = window.innerHeight - 320;
- (this as any).$refs.moduleView.$refs[tableId].recalculate();
- }
- //短驳处理
- shortBargeHandel(){
- let data = (this.$refs.moduleView as any).getSelectData();
- if(!data || data.length == 0) {
- this.$message('请选择数据');
- return
- }
- if(this.$refs.batchbyOneModal){
- (this.$refs.batchbyOneModal as any).setShow(true);
- (this.$refs.batchbyOneModal as any).setValue(data)
- }
- }
- // 获取列表数据
- getDataList() {
- if (!this.$refs.moduleView) {
- if (this.timeNum > 5) {
- clearInterval(this.timer)
- }
- this.timeNum++;
- return
- }
- clearInterval(this.timer)
- // this.getPageList(); //旧代码无分页
-
- // 新分页
- let query = (this.$refs.moduleView as any).getQuery();
- this.newsGetPageList(query)
- }
- // 新分页
- newsGetPageList(query : any) {
- let loading = this.$loading({ target: '.main-container' });
- api.getMaterialInventory().then((res : any) => {
- if (res.code === 200) {
- this.skuInfo = res.data;
- } else loading.close();
- }).then(() => {
- api.pageList({}, 'maindataStorehouse').then((res : any) => {
- if (res.code === 200) {
- this.storeHouseInfo = res.data.records;
- } else loading.close();
- if (res.code === 200) {
- let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
- this.storeHouseInfo = res.data.records;
- res.data.records.map((v : any, i : any) => {
- moduleConfig.columns.push({
- // width: '150px',
- title: v.name,
- field: 'custom' + i,
- });
- });
- (this as any).$refs.moduleView.setTableConfig(moduleConfig);
- }
- }).then(() => {
- api.pageList(query, 'maindataMaterialSku').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- for (let i = 0; i < res.data.records.length; i++) {
- for (let j = 0; j < this.storeHouseInfo.length; j++) {
- let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
- if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
- }
- }
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- this.tableInfo = res.data.records;
- loading.close();
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.moduleView as any).setPage(page);
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- }).catch(() => loading.close());
- }).catch(() => loading.close());
- }
-
- //旧代码无分页
- getPageList() {
- let loading = this.$loading({ target: '.main-container' });
- api.getMaterialInventory().then((res : any) => {
- if (res.code === 200) {
- this.skuInfo = res.data;
- } else loading.close();
- }).then(() => {
- api.pageList({}, 'maindataStorehouse').then((res : any) => {
- if (res.code === 200) {
- this.storeHouseInfo = res.data.records;
- } else loading.close();
- if (res.code === 200) {
- let moduleConfig = (this as any).$lodash.cloneDeep(this.config.table);
- this.storeHouseInfo = res.data.records;
- res.data.records.map((v : any, i : any) => {
- moduleConfig.columns.push({
- width: '120px',
- title: v.name,
- field: 'custom' + i,
- });
- });
- // moduleConfig.columns.push({
- // width: 120,
- // title: '操作',
- // action: true,
- // plugins: [{
- // name: '短驳',
- // event: {
- // click: (item : any) => {
- // (this as any).shortBarge(item)
- // }
- // }
- // }, {
- // name: '调拨',
- // event: {
- // click: (item : any) => (this as any).allocate(item)
- // }
- // }]
- // });
- (this as any).$refs.moduleView.setTableConfig(moduleConfig);
- }
- }).then(() => {
- api.pageList({
- pageNo: 1,
- pageSize: 20,
- }, 'maindataMaterialSku').then((res : any) => {
- if (res.code === 200) {
- for (let i = 0; i < res.data.records.length; i++) {
- for (let j = 0; j < this.storeHouseInfo.length; j++) {
- let nowData = this.skuInfo.filter((v : any) => v.skuId == res.data.records[i].id && v.storeHouseId == this.storeHouseInfo[j].id);
- if (nowData[0]) res.data.records[i]['custom' + j] = nowData[0].inventory;
- }
- }
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- this.tableInfo = res.data.records;
- loading.close();
- // let page = {
- // pageNo: res.data.current, //当前页
- // pageSize: res.data.size, //每页条数
- // total: res.data.total //总条数
- // };
- // (this.$refs.moduleView as any).setPage(page);
- } else loading.close();
- }).catch(() => loading.close());
- }).catch(() => loading.close());
- }).catch(() => loading.close());
- }
- // 查询
- search() {
- let searchID : any = (this as any).$refs.moduleView.searchID;
- let value = (this as any).$refs.moduleView.$refs[searchID].value;
- if (value.skuTitle) {
- if (value.skuCode) {
- // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode && v.skuTitle == value.skuTitle);
- let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1 && v.skuTitle.indexOf(value.skuTitle)>-1);
- (this.$refs.moduleView as any).setTableValue(newData);
- } else {
- // let newData = this.tableInfo.filter((v : any) => v.skuTitle == value.skuTitle);
- let newData = this.tableInfo.filter((v : any) => v.skuTitle.indexOf(value.skuTitle)>-1);
- (this.$refs.moduleView as any).setTableValue(newData);
- }
- } else {
- if (value.skuCode) {
- // let newData = this.tableInfo.filter((v : any) => v.skuCode == value.skuCode);
- let newData = this.tableInfo.filter((v : any) => v.skuCode.indexOf(value.skuCode)>-1);
- (this.$refs.moduleView as any).setTableValue(newData);
- } else this.getDataList();
- }
- }
- // 短驳
- shortBarge(e : any) {
- // console.log(e);
- }
- // 调拨
- allocate(item : any) {
- // console.log(item);
- }
- // 刷新/重置
- onRefresh() {
- (this as any).$refs.moduleView.clearSearch();
- this.getDataList();
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-container {
- width: 100%;
- box-sizing: border-box;
- display: flex;
- padding: 16px;
- height: 100%;
- .bill-left {
- position: relative;
- border-right: solid #EEE 1px;
- flex-shrink: 0;
- .bill-tab {
- width: 150px;
- height: 100%;
- transition: all .5s;
- overflow: hidden;
- }
- .tab-title {
- font-size: 16px;
- padding-bottom: 16px;
- width: 200px;
- }
- }
- .bill-main {
- width: 100%;
- box-sizing: border-box;
- position: relative;
- height: 100%;
- overflow-y: hidden;
- }
- }
- </style>
|