Ben Lin
2024-06-20 de7e6c408b6209158b08991d729c4bcc72055eec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
  <PageWrapper dense contentFullHeight contentClass="flex">
    <WareHouseTree class="w-1/4 xl:w-1/5" @select="handleSelect" @delete="handleDelete" />
    <WareHouseForm v-if="WareHouse" class="w-3/4 xl:w-4/5 m-4" @success="handleSuccess" :data="Wdata"></WareHouseForm>
    <RegionForm v-if="Region" class="w-3/4 xl:w-4/5 m-4" @success="handleSuccess" :data="Rdata"></RegionForm>
    <ShelfForm v-if="Shelf" class="w-3/4 xl:w-4/5 m-4" @success="handleSuccess" :data="Sdata" :whcode="wh_code"></ShelfForm>
  </PageWrapper>
</template>
<script lang="ts">
import { defineComponent, reactive, ref } from 'vue';
 
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { PageWrapper } from '/@/components/Page';
import WareHouseTree from './WareHouseTree.vue';
import WareHouseForm from './WareHouseForm.vue';
import RegionForm from './RegionForm.vue';
import ShelfForm from './ShelfForm.vue';
import { useModal } from '/@/components/Modal';
import { useGo } from '/@/hooks/web/usePage';
import { getAccParams, DeleteUser } from '/@/api/tigerapi/account';
 
import { getWHList } from '/@/api/tigerapi/wms/house';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
//import { WhListItem, RegionListItem, ShelfListItem } from '@/api/model/warehoueseModel';
 
export default defineComponent({
  name: 'AccountManagement',
  components: { BasicTable, PageWrapper, WareHouseTree, TableAction, WareHouseForm, RegionForm, ShelfForm },
  setup() {
    //var wareHouse=reactive<WhListItem>({})
    const go = useGo();
    const [registerModal, { openModal }] = useModal();
    const searchInfo = reactive<Recordable>({});
    const [registerTable, { reload, updateTableDataRecord }] = useTable({
      title: t('账号列表'),
      api: getAccParams,
      rowKey: 'ID',
      formConfig: {
        labelWidth: 120,
        autoSubmitOnEnter: true,
      },
      useSearchForm: true,
      showTableSetting: true,
      bordered: true,
      canResize:true,
      handleSearchInfoFn(info) {
        console.log('handleSearchInfoFn', info);
        return info;
      },
      actionColumn: {
        width: 120,
        title: t('操作'),
        dataIndex: 'action',
        slots: { customRender: 'action' },
      },
    });
 
    function handleCreate() {
      openModal(true, {
        isUpdate: false,
      });
    }
    var Wdata=ref();
    var Rdata=ref();
    var Sdata=ref();
    var wh_code=ref();
    async function handleEdit(params: string) {
      var Code = params;
      var data = await getWHList(params)
      if (params.slice(0, 1) == 'W') {
        Wdata.value = data
        wh_code.value=data[0].WH_CODE
        WareHouse.value=false;
      }
      if (params.slice(0, 1) == 'R') {
        Rdata.value = data
        Region.value=false;
      }
      if (params.slice(0, 1) == 'S') {
        Sdata.value = data
        Shelf.value=false;
      }
    }
 
    function handleDelete(record: Recordable) {
      WareHouse.value=false
      Region.value=false
      Shelf.value=false
    }
 
    function handleSuccess({ isUpdate, values }) {
      if (isUpdate) {
        // 演示不刷新表格直接更新内部数据。
        // 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
        const result = updateTableDataRecord(values.ID, values);
        /*console.log(result);*/
      } else {
        reload();
      }
    }
 
    var WareHouse = ref(false);
    var Region = ref(false);
    var Shelf = ref(false);
    async function handleSelect(WareHouseCode) {
      // WareHouse.value=false;
      // Region.value=false;
      // Shelf.value=false;
      await handleEdit(WareHouseCode)
      WareHouse.value = WareHouseCode.slice(0, 1) == 'W' ? true : false;
      Region.value = WareHouseCode.slice(0, 1) == 'R' ? true : false;
      Shelf.value = WareHouseCode.slice(0, 1) == 'S' ? true : false;
      
      //WareHouse.value=WareHouseCode==''?false:true;
      //searchInfo.deptCode = WareHouseCode;
      console.log(WareHouseCode, 15);
      reload();
    }
 
    function handleView(record: Recordable) {
      //console.log(1,record);
      go('/account_detail/' + record.USER_ID);
    }
 
    return {
      registerTable,
      registerModal,
      handleCreate,
      handleEdit,
      handleDelete,
      handleSuccess,
      handleSelect,
      handleView,
      searchInfo,
      WareHouse,
      Region,
      Shelf,
      Wdata,
      Rdata,
      Sdata,
      wh_code,
      t
    };
  },
});
</script>
<style>
.addHouse {
  position: relative;
  left: 10px;
  top: 20px;
  height: 0px;
}
</style>