index.vue 14 KB

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