index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <div id="warehouseDefinition_index">
  3. <el-card shadow="nvner">
  4. <el-form :model="formData" ref="formName" label-width="100px">
  5. <el-row>
  6. <el-col :span="4">
  7. <el-form-item label="仓库编码" prop="code">
  8. <el-input
  9. placeholder="请输入"
  10. v-model="formData.code"
  11. clearable
  12. class="w100"
  13. ></el-input> </el-form-item
  14. ></el-col>
  15. <el-col :span="4">
  16. <el-form-item label="仓库名称" prop="name">
  17. <el-input
  18. placeholder="请输入"
  19. v-model="formData.name"
  20. clearable
  21. class="w100"
  22. ></el-input> </el-form-item
  23. ></el-col>
  24. <el-col :span="4">
  25. <el-form-item label="仓库类型" prop="inventoryType">
  26. <el-select
  27. filterable
  28. size="small"
  29. class="w100"
  30. v-model="formData.inventoryType"
  31. placeholder="请选择"
  32. :clearable="true"
  33. >
  34. <el-option
  35. v-for="item in inventoryTypeList"
  36. :key="item.id"
  37. :label="item.name"
  38. :value="item.id"
  39. >
  40. </el-option>
  41. </el-select> </el-form-item
  42. ></el-col>
  43. <el-col :span="4">
  44. <el-form-item label="所属工厂" prop="factoryId">
  45. <el-select
  46. filterable
  47. placeholder="请选择"
  48. v-model="formData.factoryId"
  49. clearable
  50. class="w100"
  51. >
  52. <el-option
  53. v-for="item in factoryList"
  54. :key="item.id"
  55. :label="item.name"
  56. :value="item.id"
  57. ></el-option>
  58. </el-select> </el-form-item
  59. ></el-col>
  60. <el-col :span="4">
  61. <el-form-item label="空货位数">
  62. <div class="divider11">
  63. <el-col :span="9">
  64. <el-form-item label="" prop="emptyAllocationStart">
  65. <el-input
  66. type="text"
  67. @input="
  68. (value) =>
  69. (formData.emptyAllocationStart = value.replace(
  70. /[^\d]+/g,
  71. ''
  72. ))
  73. "
  74. v-model="formData.emptyAllocationStart"
  75. ></el-input
  76. ></el-form-item>
  77. </el-col>
  78. <div class="divider111"> <el-divider></el-divider></div>
  79. <el-col :span="9">
  80. <el-form-item label="" prop="emptyAllocationEnd">
  81. <el-input
  82. type="text"
  83. @input="
  84. (value) =>
  85. (formData.emptyAllocationEnd = value.replace(
  86. /[^\d]+/g,
  87. ''
  88. ))
  89. "
  90. v-model="formData.emptyAllocationEnd"
  91. ></el-input> </el-form-item
  92. ></el-col>
  93. </div>
  94. </el-form-item>
  95. </el-col>
  96. <!-- <el-col :span="5">
  97. <el-form-item label="组织机构:" prop="deptIds">
  98. <auth-selection
  99. data-type="Array"
  100. v-model="formData.deptIds"
  101. style="width: 100%"
  102. ></auth-selection>
  103. </el-form-item>
  104. </el-col> -->
  105. <el-col :span="3" style="display: flex; justify-content: flex-end">
  106. <div>
  107. <el-button icon="el-icon-refresh-left" @click="reset"
  108. >重置</el-button
  109. >
  110. <el-button type="primary" icon="el-icon-search" @click="search"
  111. >搜索</el-button
  112. >
  113. </div>
  114. </el-col>
  115. </el-row>
  116. </el-form>
  117. <div>
  118. <el-button type="primary" icon="el-icon-plus" @click="add"
  119. >新建仓库</el-button
  120. >
  121. <el-button plain type="primary" icon="el-icon-sort" @click="handoff"
  122. >仓库列表</el-button
  123. >
  124. </div>
  125. <div v-if="isTable" class="warehouse-container" v-loading="loading">
  126. <div
  127. class="warehouse-card_item"
  128. v-for="(item, index) in warehouse"
  129. :key="index"
  130. >
  131. <div class="warehouse-card">
  132. <h3 :class="item.enabled === 0 ? 'grey' : 'ele-bg-primary'">
  133. {{ item.code }} <span>{{ item.name }}</span>
  134. </h3>
  135. <el-row class="warehouse-card-main">
  136. <el-col
  137. :span="idx === warehouseLabel.length - 1 ? 24 : 12"
  138. class="ele-elip"
  139. v-for="(itm, idx) in warehouseLabel"
  140. :key="idx"
  141. >
  142. <span class="label">{{ itm.label }}</span>
  143. <template v-if="itm.key === 'enabled'">
  144. <span :class="item[itm.key] === 0 ? 'danger-text' : ''">{{
  145. itm.filter(item[itm.key])
  146. }}</span>
  147. </template>
  148. <template v-else-if="itm.key === 'factoryId'">
  149. <span>{{ filterFactoryId(item.factoryId) }}</span>
  150. </template>
  151. <template v-else-if="itm.filter">{{
  152. itm.filter(item[itm.key])
  153. }}</template>
  154. <template v-else>{{ item[itm.key] }}</template>
  155. </el-col>
  156. </el-row>
  157. <div class="warehouse-card-footer">
  158. <el-link type="primary" :underline="false" @click="add(item)"
  159. >修改仓库</el-link
  160. >
  161. <el-link
  162. type="primary"
  163. :underline="false"
  164. @click="locationManage(item)"
  165. >货位管理</el-link
  166. >
  167. <el-link type="primary" :underline="false" @click="details(item)"
  168. >查看详情</el-link
  169. >
  170. <el-link type="danger" :underline="false" @click="remove(item)"
  171. >删除</el-link
  172. >
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <div v-else class="warehouse-container">
  178. <ele-pro-table
  179. ref="table"
  180. :columns="columns"
  181. :datasource="warehouse"
  182. height="calc(100vh - 350px)"
  183. style="margin-bottom: 10px"
  184. full-height="calc(100vh - 116px)"
  185. tool-class="ele-toolbar-form"
  186. :selection.sync="selection"
  187. :page-size="20"
  188. @columns-change="handleColumnChange"
  189. :cache-key="cacheKeyUrl"
  190. :needPage="false"
  191. >
  192. <!-- 操作列 -->
  193. <template v-slot:action="{ row }">
  194. <el-button type="text" @click="add(row)">修改</el-button>
  195. <el-button type="text" @click="locationManage(row)">货位</el-button>
  196. <el-button type="text" @click="details(row)">详情</el-button>
  197. <el-button type="text" @click="remove(row)">删除</el-button>
  198. </template>
  199. </ele-pro-table>
  200. </div>
  201. </el-card>
  202. <WarehouseEdit ref="warehouseEditRef" @success="handleList" />
  203. </div>
  204. </template>
  205. <script>
  206. // import tablePagination from '../components/tablePagination.vue';
  207. // import {
  208. // warehouseListValuable,
  209. // warehouseRemove
  210. // } from '@/api/stockManagement/warehouseDefinition';
  211. import {
  212. warehouseDefinition_inventoryList,
  213. warehouseDefinition_statusList,
  214. useDictLabel
  215. } from '@/utils/dict/index';
  216. import { mapGetters, mapActions } from 'vuex';
  217. import dictEnum from '@/enum/dict';
  218. // import selectTree from '@/components/selectTree';
  219. import WarehouseEdit from './components/WarehouseEdit';
  220. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  221. import tabMixins from '@/mixins/tableColumnsMixin';
  222. export default {
  223. // components: { selectTree, tablePagination, WarehouseEdit },
  224. components: { WarehouseEdit },
  225. computed: {
  226. ...mapGetters(['dict', 'getDict', 'getDictValue'])
  227. },
  228. mixins: [tabMixins],
  229. data() {
  230. return {
  231. isTable: false,
  232. loading: false,
  233. formData: {
  234. deptIds: [],
  235. code: '',
  236. name: '',
  237. inventoryType: '',
  238. emptyAllocationEnd: '',
  239. emptyAllocationStart: ''
  240. },
  241. cacheKeyUrl: 'wms-c2e9664a-warehouseDefinition-index',
  242. columns: [
  243. {
  244. columnKey: 'index',
  245. label: '序号',
  246. type: 'index',
  247. width: 55,
  248. align: 'center',
  249. showOverflowTooltip: true,
  250. fixed: 'left'
  251. },
  252. {
  253. prop: 'name',
  254. label: '仓库名称',
  255. align: 'center',
  256. showOverflowTooltip: true,
  257. minWidth: 180
  258. },
  259. {
  260. prop: 'code',
  261. label: '仓库编码',
  262. align: 'center',
  263. showOverflowTooltip: true,
  264. minWidth: 180
  265. },
  266. {
  267. prop: 'code',
  268. label: '状态',
  269. align: 'center',
  270. showOverflowTooltip: true,
  271. formatter: (_row, _column, cellValue) => {
  272. return _row.status !== null
  273. ? warehouseDefinition_statusList.filter(
  274. (item) => item.code == _row.status
  275. )[0].label
  276. : '';
  277. }
  278. },
  279. {
  280. prop: 'factoryName',
  281. label: '所属工厂',
  282. align: 'center',
  283. showOverflowTooltip: true,
  284. minWidth: 180
  285. },
  286. {
  287. prop: 'inventoryName',
  288. label: '仓库类型',
  289. align: 'center',
  290. showOverflowTooltip: true,
  291. minWidth: 180
  292. },
  293. {
  294. prop: 'areaNumber',
  295. label: '库区数',
  296. align: 'center',
  297. showOverflowTooltip: true,
  298. minWidth: 130
  299. },
  300. {
  301. prop: 'goodNumber',
  302. label: '货架数',
  303. align: 'center',
  304. showOverflowTooltip: true,
  305. minWidth: 130
  306. },
  307. {
  308. prop: 'allocationNumber',
  309. label: '货位数',
  310. align: 'center',
  311. showOverflowTooltip: true,
  312. minWidth: 130
  313. },
  314. {
  315. prop: 'emptyAllocationNumber',
  316. label: '空货位数',
  317. align: 'center',
  318. showOverflowTooltip: true,
  319. minWidth: 130
  320. },
  321. {
  322. columnKey: 'action',
  323. label: '操作',
  324. width: 250,
  325. align: 'center',
  326. resizable: false,
  327. slot: 'action',
  328. showOverflowTooltip: true,
  329. fixed: 'right'
  330. }
  331. ],
  332. warehouseDefinition_statusList,
  333. warehouseDefinition_inventoryList: [
  334. { code: 1, label: '物料仓' },
  335. { code: 2, label: '产品仓' },
  336. { code: 3, label: '设备仓' },
  337. { code: 4, label: '模具仓' },
  338. { code: 5, label: '舟皿仓' },
  339. { code: 6, label: '备品备件仓' }
  340. ],
  341. factoryList: [],
  342. treeList: [],
  343. warehouse: [],
  344. typeList: [],
  345. warehouseLabel: [
  346. {
  347. label: '状态',
  348. key: 'status',
  349. filter: useDictLabel(warehouseDefinition_statusList)
  350. },
  351. {
  352. label: '仓库类型',
  353. key: 'inventoryName'
  354. // filter: (value) => {
  355. // return this.getDictValue('仓库类型', value);
  356. // }
  357. },
  358. { label: '库区数', key: 'areaNumber' },
  359. { label: '货架数', key: 'goodNumber' },
  360. { label: '货位数', key: 'allocationNumber' },
  361. { label: '空货位数', key: 'emptyAllocationNumber' },
  362. { label: '所属工厂', key: 'factoryId' }
  363. ],
  364. inventoryTypeList: []
  365. };
  366. },
  367. async created() {
  368. this.requestDict('仓库类型');
  369. this.initData();
  370. },
  371. methods: {
  372. ...mapActions('dict', ['requestDict']),
  373. filterFactoryId(factoryId) {
  374. console.log(this.factoryList);
  375. let obj = this.factoryList.find((f) => f.id === factoryId);
  376. return obj ? obj.name : '';
  377. },
  378. handoff() {
  379. this.isTable = !this.isTable;
  380. },
  381. async initData() {
  382. const res2 = await warehouseDefinition.getTreeByGroup({ type: 1 });
  383. this.inventoryTypeList = res2;
  384. //获取工厂车间列表
  385. const res = await warehouseDefinition.getFactoryarea({
  386. pageNum: 1,
  387. size: 9999,
  388. type: 1
  389. });
  390. this.factoryList = res.list;
  391. this.handleList();
  392. },
  393. async handleList() {
  394. try {
  395. this.loading = true;
  396. const res = await warehouseDefinition.list(this.formData);
  397. console.log('res--------------------');
  398. console.log(res);
  399. this.warehouse = res;
  400. } finally {
  401. this.loading = false;
  402. }
  403. },
  404. search() {
  405. this.handleList();
  406. },
  407. add(item) {
  408. let type = '新建';
  409. if (item.id) {
  410. type = '修改';
  411. }
  412. this.$refs.warehouseEditRef.open(type, item);
  413. },
  414. locationManage({ id, code, name }) {
  415. this.$router.push({
  416. path: '/warehouseManagement/warehouseDefinition/add',
  417. query: {
  418. id,
  419. code,
  420. name
  421. }
  422. });
  423. },
  424. details(data) {
  425. this.$router.push({
  426. path: '/warehouseManagement/warehouseDefinition/details',
  427. query: {
  428. id: data.id
  429. }
  430. });
  431. },
  432. edit(data) {
  433. this.$router.push({
  434. path: '/warehouseManagement/warehouseDefinition/edit',
  435. query: {
  436. id: data.id
  437. }
  438. });
  439. },
  440. reset() {
  441. this.$refs.formName.resetFields();
  442. this.search();
  443. },
  444. remove({ id, name }) {
  445. this.$confirm(`确认删除仓库${name}?`).then(async () => {
  446. // const isDeleted = await warehouseDefinition.isDelete(id);
  447. // if (isDeleted == 1) {
  448. // const res = await warehouseDefinition.delete(id);
  449. // this.$message.success('删除' + res + '!');
  450. // this.handleList();
  451. // } else {
  452. // this.$message.warning('此数据可能有关联数据,暂时无法删除!');
  453. // }
  454. const res = await warehouseDefinition.delete(id);
  455. this.$message.success('删除' + res + '!');
  456. this.handleList();
  457. });
  458. }
  459. }
  460. };
  461. </script>
  462. <style lang="scss" scoped>
  463. #warehouseDefinition_index {
  464. height: calc(100vh - 96px);
  465. width: 100%;
  466. padding: 10px;
  467. box-sizing: border-box;
  468. // element-ui样式穿透
  469. :deep(.el-card) {
  470. height: 100%;
  471. .el-card__body {
  472. height: 100%;
  473. box-sizing: border-box;
  474. display: flex;
  475. flex-direction: column;
  476. .ele-pro-table {
  477. flex: 1;
  478. display: flex;
  479. flex-direction: column;
  480. .el-table {
  481. flex: 1;
  482. // display: flex;
  483. // flex-direction: column;
  484. // .el-table__body-wrapper {
  485. // flex: 1;
  486. // }
  487. }
  488. }
  489. }
  490. .el-form-item {
  491. margin-bottom: 5px !important;
  492. }
  493. }
  494. }
  495. .divider11 {
  496. display: flex;
  497. align-items: center;
  498. }
  499. .divider111 {
  500. padding: 0 10px;
  501. flex: 1;
  502. }
  503. .devider {
  504. position: relative;
  505. padding-top: 20px;
  506. &::before {
  507. content: '';
  508. border-top: 10px solid #f2f2f2;
  509. z-index: 1;
  510. position: absolute;
  511. top: 0;
  512. left: -25px;
  513. right: -30px;
  514. }
  515. }
  516. .warehouse-container {
  517. flex: 1 0 auto;
  518. height: 0;
  519. display: flex;
  520. flex-wrap: wrap;
  521. padding-top: 20px;
  522. overflow-y: auto;
  523. .warehouse-card-placeholder {
  524. width: 25%;
  525. }
  526. .warehouse-card_item {
  527. width: 25%;
  528. padding: 0 10px;
  529. box-sizing: border-box;
  530. }
  531. .warehouse-card {
  532. // margin-right: auto;
  533. width: 100%;
  534. font-size: 14px;
  535. border: 1px solid rgb(121, 121, 121);
  536. margin-bottom: 20px;
  537. padding-bottom: 30px;
  538. position: relative;
  539. h3 {
  540. height: 35px;
  541. display: flex;
  542. justify-content: space-between;
  543. align-items: center;
  544. // background-color: $mainColor;
  545. color: #fff;
  546. padding: 8px;
  547. span {
  548. font-size: 18px;
  549. font-weight: bold;
  550. }
  551. &.grey {
  552. background-color: rgb(170, 170, 170);
  553. color: rgba(0, 0, 0, 0.85);
  554. }
  555. }
  556. .warehouse-card-main {
  557. width: 100%;
  558. padding: 8px 12px;
  559. color: rgba($color: #000000, $alpha: 0.89);
  560. .el-col {
  561. padding: 8px 0;
  562. }
  563. .label {
  564. font-weight: bold;
  565. display: inline-block;
  566. width: 4.5em;
  567. }
  568. }
  569. .warehouse-card-footer {
  570. position: absolute;
  571. bottom: 0;
  572. left: 0;
  573. right: 0;
  574. display: flex;
  575. justify-content: space-between;
  576. align-items: center;
  577. padding: 0 12px;
  578. height: 30px;
  579. background-color: rgb(242, 242, 242);
  580. }
  581. }
  582. }
  583. .p20 {
  584. padding: 20px;
  585. }
  586. .mt20 {
  587. margin-top: 20px;
  588. }
  589. .mt10 {
  590. margin-top: 10px;
  591. }
  592. .el-form {
  593. overflow: hidden;
  594. }
  595. .float-right {
  596. float: right;
  597. text-align: right;
  598. margin-right: 20px;
  599. }
  600. .right {
  601. text-align: right;
  602. }
  603. </style>