index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <div class="my-container">
  3. <transition-group name="fade" style="position: relative;width: 100%;display: flex;">
  4. <div class="bill-main" v-show="isShow==='ckb'" key="item">
  5. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  6. @resert="getDataList" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
  7. </module-view>
  8. <!-- 新增/编辑弹窗 -->
  9. <el-dialog :title="popTitle+'仓库'" :visible.sync="dialogFormVisible" width="30%">
  10. <by-form :propConfig="addConfig" ref="addFormId"></by-form>
  11. <div slot="footer" class="dialog-footer">
  12. <el-button @click="dialogFormVisible = false">取 消</el-button>
  13. <el-button type="primary" @click="confirm">确 定</el-button>
  14. </div>
  15. </el-dialog>
  16. </div>
  17. <div class="bill-main" v-show="isShow==='cwb'" key="item2">
  18. <module-view :propConfig="config2" ref="moduleView2" @clickHandle="clickHandle2" @detail="openEdit2"
  19. @pagination="getDataList2" @search="getDataList2" @resert="getDataList2" @onRefresh="onRefresh2">
  20. </module-view>
  21. <!-- 新增/编辑弹窗 -->
  22. <el-dialog :title="popTitle+'仓位'" :visible.sync="dialogFormVisible2" width="30%">
  23. <by-form :propConfig="addConfig2" ref="addFormId2">
  24. <template v-slot:organizationName="{value}">
  25. <el-input placeholder="请选择所属机构名称" size="small" v-model="value.organizationName" class="input-organizationName"
  26. :readonly="true">
  27. <el-button slot="append" icon="el-icon-more" @click="handleSupplier"></el-button>
  28. </el-input>
  29. </template>
  30. </by-form>
  31. <div slot="footer" class="dialog-footer">
  32. <el-button @click="dialogFormVisible2 = false">取 消</el-button>
  33. <el-button type="primary" @click="confirm2">确 定</el-button>
  34. </div>
  35. </el-dialog>
  36. </div>
  37. </transition-group>
  38. <supplier-modal ref="supplierModal" @confirm="confirmSupplier" :zIndex="9999" />
  39. </div>
  40. </template>
  41. <script lang="ts">
  42. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  43. import api from "@/api/currency";
  44. @Component
  45. export default class Depots extends Vue {
  46. isShow : any = 'ckb'
  47. timeNum = 0;
  48. timer : any = null
  49. timeNum2 = 0;
  50. timer2 : any = null
  51. popTitle : any = ''
  52. tableData : any = {}
  53. dialogFormVisible : boolean = false
  54. dialogFormVisible2 : boolean = false
  55. config : any = {
  56. search: {
  57. attr: {
  58. size: 'mini'
  59. },
  60. columns: [
  61. [{
  62. span: 6,
  63. label: '仓库名称',
  64. prop: 'name',
  65. component: 'by-input',
  66. labelWidth: '70px',
  67. compConfig: {
  68. attr: {
  69. placeholder: '请输入名称',
  70. clearable: true
  71. },
  72. },
  73. }, {
  74. span: 6,
  75. label: '地址',
  76. prop: 'address',
  77. component: 'by-input',
  78. labelWidth: '70px',
  79. compConfig: {
  80. attr: {
  81. placeholder: '请输入地址',
  82. clearable: true
  83. }
  84. }
  85. },
  86. ]
  87. ]
  88. },
  89. tool: {
  90. tools: {
  91. add: true,
  92. search: true,
  93. refresh: true
  94. }
  95. },
  96. table: {
  97. attr: {
  98. size: 'mini',
  99. seq: true,
  100. align: 'center',
  101. checkbox: true,
  102. height: 630
  103. },
  104. columns: [{
  105. title: '名称',
  106. field: 'name',
  107. isDetail: true,
  108. }, {
  109. title: '地址',
  110. field: 'address',
  111. }, {
  112. width: 100,
  113. title: '仓位',
  114. action: true,
  115. plugins: [{
  116. icon: 'el-icon-edit',
  117. name: '查看',
  118. audit: '',
  119. event: {
  120. click: (item : any) => {
  121. (this as any).changeTab(item)
  122. }
  123. }
  124. }]
  125. }, {
  126. width: 120,
  127. title: '操作',
  128. action: true,
  129. plugins: [{
  130. icon: 'el-icon-edit',
  131. name: '编辑',
  132. audit: '',
  133. event: {
  134. click: (item : any) => {
  135. (this as any).openEdit(item)
  136. }
  137. }
  138. }, {
  139. name: '删除',
  140. event: {
  141. click: (item : any) => (this as any).doDelete2(item, 'maindataStorehouse')
  142. }
  143. }]
  144. }]
  145. },
  146. }
  147. config2 : any = {
  148. search: {
  149. attr: {
  150. size: 'mini'
  151. },
  152. columns: [
  153. [
  154. {
  155. span: 6,
  156. label: '名称',
  157. prop: 'name',
  158. component: 'by-input',
  159. compConfig: {
  160. attr: {
  161. placeholder: '请输入名称',
  162. clearable: true
  163. },
  164. },
  165. },
  166. {
  167. span: 6,
  168. label: '所属机构名称',
  169. prop: 'organizationName',
  170. component: 'by-input',
  171. compConfig: {
  172. attr: {
  173. placeholder: '请输入所属机构名称',
  174. clearable: true
  175. }
  176. }
  177. },
  178. {
  179. span: 6,
  180. label: '库存',
  181. prop: 'stock',
  182. component: 'by-input',
  183. compConfig: {
  184. attr: {
  185. placeholder: '请输入库存',
  186. clearable: true
  187. }
  188. }
  189. },
  190. {
  191. span: 6,
  192. label: '库存体积',
  193. prop: 'stockVolume',
  194. component: 'by-input',
  195. compConfig: {
  196. attr: {
  197. placeholder: '请输入库存体积',
  198. clearable: true
  199. },
  200. },
  201. },
  202. ],
  203. [
  204. {
  205. span: 6,
  206. label: '库存上限数量',
  207. prop: 'maxStockNumber',
  208. component: 'by-input',
  209. compConfig: {
  210. attr: {
  211. placeholder: '请输入库存上限数量',
  212. clearable: true
  213. }
  214. }
  215. },
  216. {
  217. span: 6,
  218. label: '库存体积上限',
  219. prop: 'maxStockVolume',
  220. component: 'by-input',
  221. compConfig: {
  222. attr: {
  223. placeholder: '请输入库存体积上限',
  224. clearable: true
  225. }
  226. }
  227. },
  228. ]
  229. ]
  230. },
  231. tool: {
  232. tools: {
  233. return: true,
  234. add: true,
  235. delete: true,
  236. search: true,
  237. refresh: true
  238. }
  239. },
  240. table: {
  241. attr: {
  242. size: 'mini',
  243. seq: true,
  244. align: 'center',
  245. checkbox: true,
  246. height: 590
  247. },
  248. columns: [{
  249. width: 300,
  250. title: '仓位名称',
  251. field: 'name',
  252. isDetail: true,
  253. },
  254. {
  255. width: 250,
  256. title: '仓库名称',
  257. field: 'ckName',
  258. },
  259. {
  260. width: 200,
  261. title: '所属机构名称',
  262. field: 'organizationName',
  263. },
  264. {
  265. width: 150,
  266. title: '库存',
  267. field: 'stock'
  268. },
  269. {
  270. width: 150,
  271. title: '库存体积',
  272. field: 'stockVolume'
  273. },
  274. {
  275. width: 150,
  276. title: '库存数量上限',
  277. field: 'maxStockNumber'
  278. },
  279. {
  280. width: 150,
  281. title: '库存体积上限',
  282. field: 'maxStockVolume'
  283. }, {
  284. width: 120,
  285. title: '操作',
  286. action: true,
  287. plugins: [{
  288. icon: 'el-icon-edit',
  289. name: '编辑',
  290. audit: '',
  291. event: {
  292. click: (item : any) => {
  293. (this as any).openEdit2(item)
  294. }
  295. }
  296. }, {
  297. name: '删除',
  298. event: {
  299. click: (item : any) => (this as any).doDelete3(item, 'maindataStoringLocation')
  300. }
  301. }]
  302. }]
  303. },
  304. }
  305. addConfig = {
  306. attr: {
  307. size: 'small',
  308. rules: {
  309. name: [{
  310. required: true, message: '请输入名称', trigger: 'blur'
  311. }],
  312. shortName: [{
  313. required: true, message: '请输入简称', trigger: 'blur'
  314. }]
  315. }
  316. },
  317. columns: [
  318. [
  319. {
  320. span: 23,
  321. labelWidth: '70px',
  322. label: '名称',
  323. prop: 'name',
  324. component: 'by-input',
  325. },
  326. {
  327. span: 23,
  328. labelWidth: '70px',
  329. label: '地址',
  330. prop: 'address',
  331. component: 'by-input',
  332. },
  333. ]
  334. ]
  335. }
  336. addConfig2 = {
  337. attr: {
  338. size: 'small',
  339. rules: {
  340. name: [{
  341. required: true, message: '请输入名称', trigger: 'blur'
  342. }],
  343. organizationName: [{
  344. required: true, message: '请输入所属机构名称', trigger: 'blur'
  345. }]
  346. }
  347. },
  348. columns: [
  349. [
  350. {
  351. labelWidth: '110px',
  352. span: 23,
  353. label: '名称',
  354. prop: 'name',
  355. component: 'by-input',
  356. },
  357. {
  358. labelWidth: '110px',
  359. span: 23,
  360. label: '所属机构名称',
  361. prop: 'organizationName',
  362. slot: true,
  363. // component: 'by-input',
  364. },
  365. {
  366. labelWidth: '110px',
  367. span: 23,
  368. label: '库存',
  369. prop: 'stock',
  370. component: 'by-input',
  371. },
  372. {
  373. labelWidth: '110px',
  374. span: 23,
  375. label: '库存体积',
  376. prop: 'stockVolume',
  377. component: 'by-input',
  378. },
  379. {
  380. labelWidth: '110px',
  381. span: 23,
  382. label: '库存数量上限',
  383. prop: 'maxStockNumber',
  384. component: 'by-input',
  385. },
  386. {
  387. labelWidth: '110px',
  388. span: 23,
  389. label: '库存体积上限',
  390. prop: 'maxStockVolume',
  391. component: 'by-input',
  392. },
  393. ]
  394. ]
  395. }
  396. created() {
  397. this.timer = setInterval(() => {
  398. this.getDataList()
  399. }, 500)
  400. }
  401. // 仓库确认新增/编辑
  402. confirm() {
  403. (this as any).$refs.addFormId.validate().then(() => {
  404. let query = (this as any).$refs.addFormId.getValue();
  405. console.log(query);
  406. this.dialogFormVisible = false;
  407. if (this.popTitle === '新增') {
  408. api.saveList(query, 'maindataStorehouse').then((res : any) => {
  409. if (res.code === 200) {
  410. this.$message.success(this.popTitle + '成功!');
  411. this.getDataList();
  412. } else this.$message.error(res.msg)
  413. })
  414. } else if (this.popTitle === '编辑') {
  415. api.updateList(query, 'maindataStorehouse').then((res : any) => {
  416. if (res.code === 200) {
  417. this.$message.success(this.popTitle + '成功!');
  418. this.getDataList();
  419. } else this.$message.error(res.msg)
  420. })
  421. }
  422. })
  423. }
  424. // 仓位确认新增/编辑
  425. confirm2() {
  426. (this as any).$refs.addFormId2.validate().then(() => {
  427. let query = (this as any).$refs.addFormId2.getValue();
  428. console.log('表单参数 ==> ', query);
  429. query.storehouseId = this.tableData.id;
  430. query.idDelete = 0;
  431. this.dialogFormVisible2 = false;
  432. if (this.popTitle === '新增') {
  433. api.saveList(query, 'maindataStoringLocation').then((res : any) => {
  434. if (res.code === 200) {
  435. this.$message.success(this.popTitle + '成功!');
  436. this.getOneself(query.storehouseId);
  437. } else this.$message.error(res.msg)
  438. })
  439. } else if (this.popTitle === '编辑') {
  440. api.updateList(query, 'maindataStoringLocation').then((res : any) => {
  441. if (res.code === 200) {
  442. this.$message.success(this.popTitle + '成功!');
  443. this.getOneself(query.storehouseId);
  444. } else this.$message.error(res.msg)
  445. })
  446. }
  447. })
  448. }
  449. // 通过id拿到当条数据
  450. getOneself(e : any) {
  451. api.single({ id: e }, 'maindataStorehouse').then((res : any) => {
  452. if (res.code === 200) {
  453. this.tableData = res.data;
  454. this.tableData.subList.map((v:any) => {
  455. v.ckName = this.tableData.name;
  456. });
  457. (this.$refs.moduleView2 as any).setTableValue(this.tableData.subList);
  458. }
  459. })
  460. }
  461. // 获取仓库列表数据
  462. getDataList() {
  463. if (!this.$refs.moduleView) {
  464. if (this.timeNum > 5) {
  465. clearInterval(this.timer)
  466. }
  467. this.timeNum++;
  468. return
  469. }
  470. clearInterval(this.timer)
  471. let query = (this.$refs.moduleView as any).getQuery();
  472. api.pageList(query, 'maindataStorehouse').then((res : any) => {
  473. if (res.code === 200) {
  474. (this.$refs.moduleView as any).setTableValue(res.data.records);
  475. let page = {
  476. pageNo: res.data.current, //当前页
  477. pageSize: res.data.size, //每页条数
  478. total: res.data.total //总条数
  479. };
  480. (this.$refs.moduleView as any).setPage(page)
  481. } else this.$message.error(res.msg)
  482. })
  483. }
  484. // 获取仓位列表数据
  485. getDataList2() {
  486. if (!this.$refs.moduleView2) {
  487. if (this.timeNum2 > 5) {
  488. clearInterval(this.timer2)
  489. }
  490. this.timeNum2++;
  491. return
  492. }
  493. clearInterval(this.timer2)
  494. let query = (this.$refs.moduleView2 as any).getQuery();
  495. console.log(query);
  496. query.storehouseId = this.tableData.id;
  497. api.pageList(query, 'maindataStoringLocation').then((res : any) => {
  498. if (res.code === 200) {
  499. res.data.records.map((v:any) => {
  500. v.ckName = this.tableData.name;
  501. });
  502. (this.$refs.moduleView2 as any).setTableValue(res.data.records);
  503. let page = {
  504. pageNo: res.data.current, //当前页
  505. pageSize: res.data.size, //每页条数
  506. total: res.data.total //总条数
  507. };
  508. (this.$refs.moduleView2 as any).setPage(page)
  509. } else this.$message.error(res.msg)
  510. })
  511. }
  512. // 工具栏方法
  513. clickHandle(e : any) {
  514. if (e === 'onAdd') this.onAdd();
  515. }
  516. // 工具栏方法
  517. clickHandle2(e : any) {
  518. if (e === 'onAdd') this.onAdd2();
  519. if (e === 'onDelete') this.onDelete('moduleView2', 'maindataStoringLocation');
  520. if (e === 'onReturn') this.isShow = 'ckb';
  521. }
  522. // 打开新增
  523. onAdd() {
  524. this.popTitle = '新增'
  525. this.dialogFormVisible = true;
  526. setTimeout(() => {
  527. if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue({});
  528. }, 0)
  529. }
  530. // 打开编辑
  531. openEdit(e : any) {
  532. this.popTitle = '编辑'
  533. this.dialogFormVisible = true;
  534. setTimeout(() => {
  535. if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue(e);
  536. }, 0)
  537. }
  538. // 打开新增
  539. onAdd2() {
  540. this.popTitle = '新增'
  541. this.dialogFormVisible2 = true;
  542. setTimeout(() => {
  543. if ((this as any).$refs.addFormId2) (this as any).$refs.addFormId2.setValue({});
  544. }, 0)
  545. }
  546. // 打开编辑
  547. openEdit2(e : any) {
  548. this.popTitle = '编辑'
  549. this.dialogFormVisible2 = true;
  550. setTimeout(() => {
  551. if ((this as any).$refs.addFormId2) (this as any).$refs.addFormId2.setValue(e);
  552. }, 0)
  553. }
  554. // 打开机构选择
  555. handleSupplier() {
  556. (this.$refs.supplierModal as any).setShow(true);
  557. }
  558. // 确定机构选择
  559. confirmSupplier(e : any) {
  560. if (e.length == 0) return this.$message.warning('请选择供应商!');
  561. let value : any = (this.$refs.addFormId2 as any).getValue();
  562. value.organizationName = e[0].name;
  563. value.organizationId = e[0].id;
  564. (this.$refs.addFormId2 as any).setValue(value);
  565. }
  566. // 查看仓位
  567. changeTab(item : any) {
  568. this.tableData = item;
  569. this.tableData.subList.map((v:any) => {
  570. v.ckName = this.tableData.name;
  571. })
  572. console.log('仓库表数据 ==> ', this.tableData);
  573. (this.$refs.moduleView2 as any).setTableValue(this.tableData.subList);
  574. this.isShow = 'cwb';
  575. }
  576. // 刷新仓库
  577. onRefresh() {
  578. (this as any).$refs.moduleView.clearSearch();
  579. this.getDataList();
  580. }
  581. // 刷新仓位
  582. onRefresh2() {
  583. (this as any).$refs.moduleView2.clearSearch();
  584. this.getDataList2();
  585. }
  586. // 仓库操作删除
  587. doDelete2(item : any, url : any) {
  588. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  589. confirmButtonText: '确定',
  590. cancelButtonText: '取消',
  591. type: 'warning',
  592. center: true
  593. }).then(() => {
  594. if (item.subList.length > 0) {
  595. this.$message.warning('此仓库下有仓位,不可删除!');
  596. } else {
  597. api.deleteList({ ids: item.id }, url).then((res : any) => {
  598. if (res.code === 200) {
  599. this.getDataList();
  600. this.$message.success('删除成功');
  601. } else this.$message.error(res.msg)
  602. })
  603. }
  604. }).catch(() => this.$message.info('已取消删除'));
  605. }
  606. // 仓位工具栏删除
  607. onDelete(moduleView : any, url : any) {
  608. let selectData = (this.$refs[moduleView] as any).getSelectData()
  609. let ids = '';
  610. if (selectData.length > 0) {
  611. selectData.map((v : any) => {
  612. ids += v.id + ','
  613. })
  614. } else return this.$message.warning('请选择删除数据');
  615. ids = ids.slice(0, ids.length - 1);
  616. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  617. confirmButtonText: '确定',
  618. cancelButtonText: '取消',
  619. type: 'warning',
  620. center: true
  621. }).then(() => {
  622. api.deleteList({ ids: ids }, url).then((res : any) => {
  623. if (res.code === 200) {
  624. this.getDataList2();
  625. this.$message.success('删除成功');
  626. } else this.$message.error(res.msg)
  627. })
  628. }).catch(() => this.$message.info('已取消删除'));
  629. }
  630. // 仓位操作删除
  631. doDelete3(item : any, url : any) {
  632. console.log('仓位操作删除:',item,url);
  633. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  634. confirmButtonText: '确定',
  635. cancelButtonText: '取消',
  636. type: 'warning',
  637. center: true
  638. }).then(() => {
  639. api.deleteList({ ids: item.id }, url).then((res : any) => {
  640. if (res.code === 200) {
  641. this.getDataList2();
  642. this.$message.success('删除成功');
  643. } else this.$message.error(res.msg)
  644. })
  645. }).catch(() => this.$message.info('已取消删除'));
  646. }
  647. //导出
  648. onExport() {
  649. let urlArr = '/maindata/maindataMaterial';
  650. let query = (this.$refs.moduleView as any).getQuery();
  651. (this as any).$download(urlArr + '/export', {
  652. ...query
  653. }, urlArr[urlArr.length - 1] + `_${new Date().getTime()}.xlsx`)
  654. }
  655. }
  656. </script>
  657. <style lang="scss" scoped>
  658. .my-container {
  659. width: 100%;
  660. box-sizing: border-box;
  661. display: flex;
  662. padding: 0 16px;
  663. .search-btn {
  664. width: 100%;
  665. display: flex;
  666. justify-content: flex-end;
  667. margin-bottom: 20px;
  668. }
  669. .bill-main {
  670. width: calc(100% - 16px);
  671. box-sizing: border-box;
  672. margin-left: 16px;
  673. }
  674. @media screen and (min-width: 1500px) {
  675. .bill-main {
  676. min-width: 1610px;
  677. }
  678. }
  679. }
  680. </style>