index.vue 19 KB

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